Zend_Service_Yahoo
简介
Zend_Service_Yahoo 是一个实现多个Yahoo! REST 接口的API.
Zend_Service_Yahoo 允许你使用Yahoo! 网页搜索, Yahoo! 新闻,
Yahoo! 本地(Local), Yahoo! 图片. 为了使用 Yahoo! REST API,
你必须拥有一个 Yahoo! Application ID. 要获得它, 请访问
Application ID Request Form .
用Yahoo!来搜索网页
Zend_Service_Yahoo 允许你用
webSearch() 方法来进行Yahoo! 网页搜索, 它接受一个查询字符串作为参数 ,
用一个可选的数组传递搜索选项. 更多的细节和搜索选项的信息, 请访问
Yahoo! Web Search
Documentation . webSearch() 方法返回一个
Zend_Service_Yahoo_WebResultSet 对象.
用Yahoo!来搜索网页
webSearch('PHP');
foreach ($results as $result) {
echo $result->Title .' ';
}
?>]]>
用Yahoo!来查找图片
你可以使用Zend_Service_Yahoo的 imageSearch()
方法来在Yahoo上搜索图片。 。 它接受一个查询字符串作为参数 ,用一个可选的数组传递搜索选项, 就像
webSearch() method.
更多的细节和搜索选项的信息, 请访问
Yahoo! Image Search
Documentation .
用Yahoo!来查找图片
imageSearch('PHP');
foreach ($results as $result) {
echo $result->Title .' ';
}
?>]]>
Finding Local Businesses and Services with Yahoo!
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 .
用Yahoo!查找本地商务和服务信息
localSearch('Apple Computers', array('zip' => '95014'));
foreach ($results as $result) {
echo $result->Title .' ';
}
?>]]>
搜索Yahoo! 新闻
搜索Yahoo! 新闻非常简单; 使用 newsSearch() 方法,
如下面的例子. 更多的细节和搜索选项的信息, 请访问
Yahoo! News Search
Documentation .
搜索Yahoo! 新闻
newsSearch('PHP');
foreach ($results as $result) {
echo $result->Title .' ';
}
?>]]>
Zend_Service_Yahoo 类
不同的Yahoo! 搜索类型会返回下面的这些类. 每个搜索类型返回指定类型的结果集, 我们可以很方便的对它们进行遍历,
每个结果被包含在一种类型的结果集对象中. 所有这些对象都实现了
SeekableIterator 接口, 可以很容易的进行遍历和寻找指定结果。
Zend_Service_Yahoo_ResultSet
Zend_Service_Yahoo_WebResultSet
Zend_Service_Yahoo_ImageResultSet
Zend_Service_Yahoo_LocalResultSet
Zend_Service_Yahoo_NewsResultSet
Zend_Service_Yahoo_Result
Zend_Service_Yahoo_WebResult
Zend_Service_Yahoo_ImageResult
Zend_Service_Yahoo_LocalResult
Zend_Service_Yahoo_NewsResult
Zend_Service_Yahoo_Image
Zend_Service_Yahoo_ResultSet
每类搜索特定的结果集都由这个基类扩展而成
每类搜索特定的结果集都会返回这个搜索特定的
Zend_Service_Yahoo_Result 对象.
Zend_Service_Yahoo_ResultSet::totalResults()
int
totalResults
返回搜索结果的数量
Properties
Zend_Service_Yahoo_ResultSet
名称
类型
描述
totalResultsAvailable
int
所有找到的结果的数量
totalResultsReturned
int
当前结果集中结果的数量
firstResultPosition
int
当前结果集中的第一条在所有结果中的相对位置
Back to Class List
Zend_Service_Yahoo_WebResultSet
Zend_Service_Yahoo_WebResultSet 代表 Yahoo! 网页搜索的结果集.
Zend_Service_Yahoo_WebResultSet 扩展自 Zend_Service_Yahoo_ResultSet
Back to Class List
Zend_Service_Yahoo_ImageResultSet
Zend_Service_Yahoo_ImageResultSet 代表一个 Yahoo! 图片搜索结果集
Zend_Service_Yahoo_ImageResultSet 扩展自 Zend_Service_Yahoo_ResultSet
Back to Class List
Zend_Service_Yahoo_LocalResultSet
Zend_Service_Yahoo_LocalResultSet 代表一个Yahoo!本地搜索的结果集
Zend_Service_Yahoo_LocalResultSet 属性
名称
类型
描述
resultSetMapURL
string
包含返回查询结果地图的URL
Zend_Service_Yahoo_LocalResultSet 扩展自 Zend_Service_Yahoo_ResultSet
Back to Class List
Zend_Service_Yahoo_NewsResultSet
Zend_Service_Yahoo_NewsResultSet 代表一个Yahoo!新闻搜索结果的集合
Zend_Service_Yahoo_NewsResultSet 扩展自 Zend_Service_Yahoo_ResultSet
Back to Class List
Zend_Service_Yahoo_Result
每类搜索特定的结果都由这个基类扩展而成
Properties
Zend_Service_Yahoo_Result Properties
名称
类型
描述
Title
string
结果项的标题
Url
string
结果项的url
ClickUrl
string
链接到结果项的url
Back to Class List
Zend_Service_Yahoo_WebResult
每一个网页搜索结果作为一个 Zend_Service_Yahoo_WebResult 对相返回.
属性
Zend_Service_Yahoo_WebResult 属性
名称
类型
描述
Summary
string
返回结果的摘要
MimeType
string
返回结果的mimetype
ModificationDate
string
一个以 UNIX timestamp 表示的最后修改日期.
CacheUrl
string
返回结果Yahoo! 网页搜索缓存页面的URL
CacheSize
int
Cache 项目的大小
Back to Class List
Zend_Service_Yahoo_ImageResult
每一个图片搜索结果作为一个 Zend_Service_Yahoo_ImageResult 对相返回.
属性
Zend_Service_Yahoo_ImageResult 属性
名称
类型
描述
Summary
string
返回结果的摘要
RefererUrl
string
图片引用页的URL
FileSize
int
以bytes为单位的图片大小
FileFormat
string
图片的格式 (bmp, gif, jpeg, png, etc.)
Height
int
图片的高
Width
int
图片的宽
Thumbnail
Zend_Service_Yahoo_Image
图片的缩略图
Back to Class List
Zend_Service_Yahoo_LocalResult
每一个本地搜索结果以 Zend_Service_Yahoo_LocalResult 对相返回.
属性
Zend_Service_Yahoo_LocalResult 属性
名称
类型
描述
Address
string
搜索结果的街道地址
City
string
搜索结果所在的城市
State
string
搜索结果所在的州
Phone
string
搜索结果相关的电话号码
Rating
int
用户对该结果的评分
Distance
float
从你指定的位置到搜索结果的距离
MapUrl
string
搜索结果地图的URL
BusinessUrl
string
商务网站的URL (如果知道的话)
BusinessClickUrl
string
链接到商务网站的URL (如果知道的话)
Back to Class List
Zend_Service_Yahoo_NewsResult
每一个新闻搜索结果作为一个 Zend_Service_Yahoo_NewsResult 对相返回.
属性
Zend_Service_Yahoo_NewsResult 属性
名称
类型
描述
Summary
string
返回结果的摘要
NewsSource
string
发布文章的公司
NewsSourceUrl
string
发布文章的公司的URL
Language
string
文章所用的语言
PublishDate
string
用 UNIX timestamp表示的文章发布日期
ModificationDate
string
用 UNIX timestamp表示的文章最后更新日期
Thumbnail
Zend_Service_Yahoo_Image
文章的缩略图,如果有的话
Back to Class List
Zend_Service_Yahoo_Image
所有的Yahoo!图片和新闻搜索返回的图片都作为
Zend_Service_Yahoo_Image 对相返回
Properties
Zend_Service_Yahoo_Image Properties
名称
类型
描述
Url
string
图片URL
Width
int
图片的宽
Height
int
图片的高
Back to Class List