cvs: peardoc /en/package/webservices services-yahoo.xml /en/package/webservices/services-yahoo design.xml examples.xml intro.xml

From: Date: Mon, 18 Apr 2005 18:11:25 +0000
Subject: cvs: peardoc /en/package/webservices services-yahoo.xml /en/package/webservices/services-yahoo design.xml examples.xml intro.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-5935@lists.php.net to get a copy of this message
mj Mon Apr 18 14:11:25 2005 EDT Added files: /peardoc/en/package/webservices services-yahoo.xml /peardoc/en/package/webservices/services-yahoo design.xml examples.xml intro.xml Log: * Added a first draft of the documentation for Services_Yahoo.

http://cvs.php.net/co.php/peardoc/en/package/webservices/services-yahoo.xml?r=1.1&p=1 Index: peardoc/en/package/webservices/services-yahoo.xml +++ peardoc/en/package/webservices/services-yahoo.xml <!-- $Revision: 1.1 $ --> <sect1 id="package.webservices.services-yahoo"> <title>Services_Yahoo</title> <para> Interface to the <ulink url="http://developer.yahoo.net/">Yahoo! Search API</ulink>. </para> <para> The package provides an object oriented model to communicate with Yahoo's services via their REST-based <acronym>XML</acronym> interface. </para> &package.webservices.services-yahoo.intro; &package.webservices.services-yahoo.examples; &package.webservices.services-yahoo.design; </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=webservices fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/peardoc/en/package/webservices/services-yahoo/design.xml?r=1.1&p=1 Index: peardoc/en/package/webservices/services-yahoo/design.xml +++ peardoc/en/package/webservices/services-yahoo/design.xml <!-- $Revision: 1.1 $ --> <refentry id="package.webservices.services-yahoo.design"> <refnamediv> <refname>Design</refname> <refpurpose> <classname>Services_Yahoo</classname>'s design </refpurpose> </refnamediv> <refsect1 id="package.webservices.services-yahoo.design.overview"> <title>Overview</title> <para> <classname>Services_Yahoo</classname> is split up into chunks that group similar functionality. Currently there are chunks for the interfaces to Yahoo Search and to the Content Analysis functions. </para> <para> Each chunk basically contains two top-level element in the source tree: A <filename>.php</filename> file and a directory that holds the implementation of the chunk. The file is a class that contains only one method which implements that <ulink url="http://c2.com/cgi/wiki?AbstractFactoryPattern">factory pattern</ulink>. This method dynamically loads the right file from the related directory and returns an instance of the class that implements the desired function. </para> <para> Due to this modular layout <classname>Services_Yahoo</classname> can easily be extended when Yahoo adds new functions to their <acronym>API</acronym>. </para> </refsect1> <refsect1> <title>More information</title> <para> If you would like to study the code of the package, you can do so by either downloading a release from the <ulink url="&url.pear.package;Services_Yahoo">package homepage</ulink> or by <ulink url="http://cvs.php.net/pear/Services_Yahoo">browsing the code in CVS</ulink>. </para> <para> Also the automatically generated <ulink url="&url.pear.package;Services_Yahoo/docs">API documentation</ulink> should help you. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=webservices fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/peardoc/en/package/webservices/services-yahoo/examples.xml?r=1.1&p=1 Index: peardoc/en/package/webservices/services-yahoo/examples.xml +++ peardoc/en/package/webservices/services-yahoo/examples.xml <!-- $Revision: 1.1 $ --> <refentry id="package.webservices.services-yahoo.examples"> <refnamediv> <refname>Examples</refname> <refpurpose> Using <classname>Services_Yahoo</classname> </refpurpose> </refnamediv> <refsect1> <title>About the examples</title> <para> The following sections provide you with examples of using the different feature sets of <classname>Services_Yahoo</classname>. Currently this includes documentation for the interfaces to <link linkend="package.webservices.services-yahoo.example.search">Yahoo! Search</link> and <link linkend="package.webservices.services-yahoo.example.contentanalysis">Content Analysis</link>. </para> <note> <para> The examples are designed to be run from a command line shell. If you would like to test them in a web browser you should replace <literal>\n</literal> with <literal>&lt;br /&gt;</literal> for better readability. </para> </note> </refsect1> <refsect1 id="package.webservices.services-yahoo.example.search"> <title>Speaking to Yahoo! Search</title> <para> The following examples will communicate with <ulink url="http://search.yahoo.com/">Yahoo! Search</ulink>. </para> <example> <title>Web search: Listing results</title> <para> This snippet issues a search query for the term <literal>Steve Fossett</literal> to Yahoo! Search. For each result in the returned result set the title is printed. </para> <programlisting role="php"> <![CDATA[ require_once "Services/Yahoo/Search.php"; try { $search = Services_Yahoo_Search::factory("web"); $search->setQuery("Steve Fossett"); $results = $search->submit(); echo "Number of results: " . $results->getTotalResultsReturned() . "\n\n"; foreach ($results as $result) { echo $result['Title'] . "\n"; } } catch (Services_Yahoo_Exception $e) { echo "Error: " . $e->getMessage() . "\n"; foreach ($e->getErrors() as $error) { echo "* " . $error . "\n"; } } ]]> </programlisting> <para> By default 10 results are returned per request. This number can be modified using the method <function>setResultNumber</function>: </para> <programlisting role="php"> <![CDATA[ require_once "Services/Yahoo/Search.php"; try { $search = Services_Yahoo_Search::factory("web"); $search->setQuery("Steve Fossett"); // Get 20 results per query $search->setResultNumber(20); /* ... */ ]]> </programlisting> </example> <example> <title>Web search: Result details</title> <para> This code again queries Yahoo! Search for <literal>Steve Fossett</literal>, but this time the details of the first result in the result set are printed. </para> <programlisting role="php"> <![CDATA[ require_once "Services/Yahoo/Search.php"; try { $search = Services_Yahoo_Search::factory("web"); $search->setQuery("Steve Fossett"); $results = $search->submit(); if ($results->getTotalResultsReturned() > 0) { $info = $results->current(); echo "Title: " . $info['Title'] . "\n"; echo "Summary: " . $info['Summary'] . "\n"; echo "URL: " . $info['Url'] . "\n"; echo "clickable URL: " . $info['ClickUrl'] . "\n"; echo "Modification date: " . $info['ModificationDate'] . "\n"; echo "Mime type: " . $info['MimeType'] . "\n"; } } catch (Services_Yahoo_Exception $e) { echo "Error: " . $e->getMessage() . "\n"; foreach ($e->getErrors() as $error) { echo "* " . $error . "\n"; } } ]]> </programlisting> </example> <example> <title>Web search: Paginating results</title> <para> In this example the &quot;paginating&quot; capabilities of <classname>Services_Yahoo</classname> are shown. Paginating means that the search results are split up into chunks of e.g. 20, which are displayed together with links to jump back and forth to other result chunks. Basically this mimicks the functionality from the bottom of <ulink url="http://search.yahoo.com/search?ei=UTF-8&amp;fr=sfp&amp;p=steve+fossett">official Yahoo Search Page</ulink>. </para> <para> TBD </para> </example> </refsect1> <refsect1 id="package.webservices.services-yahoo.example.contentanalysis"> <title>Using the Yahoo! Content Analysis services</title> <para> The following examples will show you how to use the Content Analysis Services provided by Yahoo!. </para> <example> <title>Term Extraction Service</title> <para> The Term Extraction service provides a list of significant words or phrases extracted from a larger content. </para> <programlisting role="php"> <![CDATA[ require_once "Services/Yahoo/ContentAnalysis.php"; try { $search = Services_Yahoo_ContentAnalysis::factory("termExtraction"); $search->setContext("Italian sculptors and painters of the " . "renaissance favored the Virgin Mary for inspiration."); $search->setQuery("madonna"); $results = $search->submit(); foreach ($results as $result) { echo $result . "\n"; } } catch (Services_Yahoo_Exception $e) { echo "Error: " . $e->getMessage() . "\n"; foreach ($e->getErrors() as $error) { echo "* " . $error . "\n"; } } ]]> </programlisting> <para> It is possible to skip the call to <function>setQuery</function>. The parameter set by this method is intended to help the engine with the extraction process, but it is not stricly required. </para> </example> <example> <title>Spelling Suggestion Service</title> <para> The Spelling Suggestion service provides a suggested spelling correction for a given term. </para> <programlisting role="php"> <![CDATA[ require_once "Services/Yahoo/ContentAnalysis.php"; try { $search = Services_Yahoo_ContentAnalysis::factory("spellingSuggestion"); $search->setQuery("madnna"); $results = $search->submit(); foreach ($results as $result) { echo $result . "\n"; } } catch (Services_Yahoo_Exception $e) { echo "Error: " . $e->getMessage() . "\n"; foreach ($e->getErrors() as $error) { echo "* " . $error . "\n"; } } ]]> </programlisting> </example> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=webservices fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/co.php/peardoc/en/package/webservices/services-yahoo/intro.xml?r=1.1&p=1 Index: peardoc/en/package/webservices/services-yahoo/intro.xml +++ peardoc/en/package/webservices/services-yahoo/intro.xml <!-- $Revision: 1.1 $ --> <refentry id="package.webservices.services-yahoo.intro"> <refnamediv> <refname>Introduction</refname> <refpurpose> Introduction to <classname>Services_Yahoo</classname> </refpurpose> </refnamediv> <refsect1 id="package.webservices.services-yahoo.intro.overview"> <title>Overview</title> <para> The package provides an object oriented model to communicate with <ulink url="http://yahoo.com/">Yahoo</ulink>'s <ulink url="http://developer.yahoo.net/">web services</ulink> via their REST-based <acronym>XML</acronym> interface. </para> <para> Currently the package only supports the Yahoo! Search Web Services, which is natural because Yahoo! does not expose other services via their <acronym>API</acronym> at the moment. Due to the modular layout of the package it is easy to add support for other services at a later point though. More information about the design of the package is available in a <link linkend="package.webservices.services-yahoo.design">separate section</link>. </para> </refsect1> <refsect1 id="package.webservices.services-yahoo.intro.setup"> <title>Setup</title> <refsect2> <title>Requirements</title> <para> <classname>Services_Yahoo</classname> requires <ulink url="&url.php;">PHP 5</ulink> and a bunch of PEAR packages. For a complete list of dependencies please see the <ulink url="http://pear.php.net/package/Services_Yahoo/download">download page</ulink>. </para> </refsect2> <refsect2> <title>Installation</title> <para> The <classname>Services_Yahoo</classname> package can be installed using the PEAR installer command <command>pear install Services_Yahoo</command>. If the installation fails due to missing dependencies, one either needs to install them manually or can make the installer fetch all dependencies automatically: <command>pear install -a Services_Yahoo</command>. </para> </refsect2> <refsect2> <title>Uninstallation</title> <para> Uninstalling the package can be done with <command>pear uninstall Services_Yahoo</command>. </para> </refsect2> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=webservices fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
« previous php.pear.doc (#5935) next »