Zend_Service_Yahoo
is a simple API for using many of the Yahoo! REST APIs.
Zend_Service_Yahoo
allows you to search Yahoo! Web search, Yahoo! News, Yahoo! Local, Yahoo!
Images. In order to use the Yahoo! REST API, you must have a Yahoo! Application ID. To obtain an Application ID, please complete and submit the
Application ID Request Form.
Zend_Service_Yahoo
enables you to search the Web with Yahoo! using the
webSearch()
method, which accepts a string query parameter and an optional second parameter
as an array of search options. For full details and an option list, please visit the
Yahoo! Web Search
Documentation. The webSearch()
method returns a
Zend_Service_Yahoo_WebResultSet
object.
You can search for Images with Yahoo using Zend_Service_Yahoo
's imageSearch()
method. This method accepts a string query parameter and an optional array of search options, as for the
webSearch()
method. For full details
and an option list, please visit the
Yahoo! Image Search
Documentation.
You can search for local businesses and services with Yahoo! by using the localSearch()
method.
For full details, please see the
Yahoo! Local Search
Documentation.
Пример 15.13. Finding Local Businesses and Services with Yahoo!
<?php require_once 'Zend/Service/Yahoo.php'; $yahoo = new Zend_Service_Yahoo("YAHOO_APPLICATION_ID"); $results = $yahoo->localSearch('Apple Computers', array('zip' => '95014')); foreach ($results as $result) { echo $result->Title .'<br />'; } ?>
Searching Yahoo! News is simple; just use the newsSearch()
method, as in the following
example. For full details, please see the
Yahoo! News Search
Documentation.
The following classes are all returned by the various Yahoo! searches. Each search type returns a
type-specific result set which can be easily iterated, with each result being contained in a type result
object. All result set classes implement the SeekableIterator
interface, allowing for easy
iteration and seeking to a specific result.
Each of the search specific result sets is extended from this base class.
Each of the specific result sets returns a search specific Zend_Service_Yahoo_Result objects.
int totalResults();
Returns the number of results returned for the search.
Zend_Service_Yahoo_WebResultSet
represents a Yahoo! Web Search result set
result set.
Замечание | |
---|---|
|
Zend_Service_Yahoo_ImageResultSet
represents a Yahoo! Image Search result set
result set.
Замечание | |
---|---|
|
Zend_Service_Yahoo_LocalResultSet
represents a Yahoo! Local Search result set
result set.
Таблица 15.14. Zend_Service_Yahoo_LocalResultSet Properties
Name | Type | Description |
---|---|---|
resultSetMapURL | string | The URL of a webpage containing a map graphic with all returned results plotted on it. |
Замечание | |
---|---|
|
Zend_Service_Yahoo_NewsResultSet
represents a Yahoo! News Search result set
result set.
Замечание | |
---|---|
|
Each of the search specific results is extended from this base class.
Each Web Search result is returned as a Zend_Service_Yahoo_WebResult
object.
Таблица 15.16. Zend_Service_Yahoo_WebResult Properties
Name | Type | Description |
---|---|---|
Summary | string | Result summary |
MimeType | string | Result mimetype |
ModificationDate | string | The last modification date of the result as a UNIX timestamp. |
CacheUrl | string | Yahoo! web cache URL for the result, if it exists. |
CacheSize | int | The size of the Cache entry |
Each Image Search result is returned as a Zend_Service_Yahoo_ImageResult
object.
Таблица 15.17. Zend_Service_Yahoo_ImageResult Properties
Name | Type | Description |
---|---|---|
Summary | string | Result summary |
RefererUrl | string | The URL of the page which contains the image |
FileSize | int | The size of the image file in bytes |
FileFormat | string | The format of the image (bmp, gif, jpeg, png, etc.) |
Height | int | The height of the image |
Width | int | The width of the image |
Thumbnail | Zend_Service_Yahoo_Image | Image thumbnail |
Each Local Search result is returned as a Zend_Service_Yahoo_LocalResult
object.
Таблица 15.18. Zend_Service_Yahoo_LocalResult Properties
Name | Type | Description |
---|---|---|
Address | string | Street Address of the result |
City | string | City in which the result resides in |
State | string | State in which the result resides in |
Phone | string | Phone number for the result |
Rating | int | User submitted rating for the result |
Distance | float | The distance to the result from your specified location |
MapUrl | string | A URL of a map for the result |
BusinessUrl | string | The URL for the business website, if known |
BusinessClickUrl | string | The URL for linking to the business website, if known |
Each News Search result is returned as a Zend_Service_Yahoo_NewsResult
object.
Таблица 15.19. Zend_Service_Yahoo_NewsResult Properties
Name | Type | Description |
---|---|---|
Summary | string | Result summary |
NewsSource | string | The company who distributed the article |
NewsSourceUrl | string | The URL for the company who distributed the article |
Language | string | The language the article is in |
PublishDate | string | The date the article was published as a UNIX timestamp |
ModificationDate | string | The date the article was last modified as a UNIX timestamp |
Thumbnail | Zend_Service_Yahoo_Image | Image Thumbnail for the article, if it exists |
All images returned either by the Yahoo! Image Search of the Yahoo! News Search
are represented by Zend_Service_Yahoo_Image
objects