0

我正在阅读有关 Zend_Service_Flickr 的页面。但是它没有说明如何设置显示的照片数量。

以下代码返回 10 张图像。

Zend_Loader::loadClass('Zend_Service_Flickr');
$flickr = new Zend_Service_Flickr($this->flickrapikey);
$results = $flickr->userSearch($this->flickemail);

谁能告诉我如何设置它?

提前致谢。

4

1 回答 1

1

如果您查看(例如,Zend_Service_Flickr::userSearch 请参见此处)的代码源,您会注意到它以这段代码开头:

/**
 * Finds photos by a user's username or email.
 *
 * Additional query options include:
 *
 *  # per_page:        how many results to return per query
 *  # page:            the starting page offset.  first result will be (page - 1) * per_page + 1
 *  # min_upload_date: Minimum upload date to search on.  Date should be a unix timestamp.
 *  # max_upload_date: Maximum upload date to search on.  Date should be a unix timestamp.
 *  # min_taken_date:  Minimum upload date to search on.  Date should be a MySQL datetime.
 *  # max_taken_date:  Maximum upload date to search on.  Date should be a MySQL datetime.
 *
 * @param  string $query   username or email
 * @param  array  $options Additional parameters to refine your query.
 * @return Zend_Service_Flickr_ResultSet
 * @throws Zend_Service_Exception
 */
public function userSearch($query, array $options = null)
{
    static $method = 'flickr.people.getPublicPhotos';
    static $defaultOptions = array('per_page' => 10,
                                   'page'     => 1,
                                   'extras'   => 'license, date_upload, date_taken, owner_name, icon_server');
    ...
    ...

这应该足以帮助您了解如何指定要获取多少张照片:您可能只需要传递一个数组作为第二个参数,其中包含一个带有键“ per_page”的条目以及您想要的值。

像这样的东西,我想(虽然没有尝试过)

Zend_Loader::loadClass('Zend_Service_Flickr');
$flickr = new Zend_Service_Flickr($this->flickrapikey);
$results = $flickr->userSearch($this->flickemail, array(
    'per_page' => 20
  ));

当文档不够好时,不要犹豫,看看代码 ;-)

于 2009-11-24T07:39:42.880 回答