Proposal for "Services_Yahoo"

» Metadata » Status
  • Category: Web Services
  • Proposer: Martin Jansen 
  • License: PHP License
» Description
Interface to the Yahoo! Search API. The package provides an object oriented model to communicate with Yahoo's services via their REST-based XML interface.

Currently the package only supports the Yahoo! Search Web Services, which is natural because Yahoo! does not expose other services via their API 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.

Documentation will be written as soon (resp. if) this package is accepted.


The following code queries Yahoo! Search for the term "Steve Fosset" and prints a list of the results.

require_once "Services/Yahoo/Search.php";

try {
$search = Services_Yahoo_Search::factory("news");
$search->setQuery("Steve Fosset");

$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";

Replacing "news" as the parameter for the factory method with one of "web", "image", "video" or "local" will run the same query against the other Yahoo! search services.
» Dependencies » Links
  • HTTP_Request
  • PHP 5
» Timeline » Changelog
  • First Draft: 2005-03-01
  • Proposal: 2005-03-04
  • Call for Votes: 2005-03-15