photos.php

来自「Bug tracker, and reporter.」· PHP 代码 · 共 562 行 · 第 1/2 页

PHP
562
字号
<?php/** * Zend Framework * * LICENSE * * This source file is subject to the new BSD license that is bundled * with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://framework.zend.com/license/new-bsd * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to license@zend.com so we can send you a copy immediately. * * @category   Zend * @package    Zend_Gdata * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license    http://framework.zend.com/license/new-bsd     New BSD License *//** * @see Zend_Gdata */require_once 'Zend/Gdata.php';/** * @see Zend_Gdata_Photos_UserFeed */require_once 'Zend/Gdata/Photos/UserFeed.php';/** * @see Zend_Gdata_Photos_AlbumFeed */require_once 'Zend/Gdata/Photos/AlbumFeed.php';/** * @see Zend_Gdata_Photos_PhotoFeed */require_once 'Zend/Gdata/Photos/PhotoFeed.php';/** * Service class for interacting with the Google Photos Data API. *  * Like other service classes in this module, this class provides access via  * an HTTP client to Google servers for working with entries and feeds. *  * @link http://code.google.com/apis/picasaweb/gdata.html * * @category   Zend * @package    Zend_Gdata * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license    http://framework.zend.com/license/new-bsd     New BSD License */class Zend_Gdata_Photos extends Zend_Gdata{        const PICASA_BASE_URI = 'http://picasaweb.google.com/data';    const PICASA_BASE_FEED_URI = 'http://picasaweb.google.com/data/feed';    const AUTH_SERVICE_NAME = 'lh2';        /**     * Default projection when interacting with the Picasa server.     */    const DEFAULT_PROJECTION = 'api';        /**     * The default visibility to filter events by.     */    const DEFAULT_VISIBILITY = 'all';        /**     * The default user to retrieve feeds for.     */    const DEFAULT_USER = 'default';        /**     * Path to the user feed on the Picasa server.     */    const USER_PATH = 'user';        /**     * Path to album feeds on the Picasa server.     */    const ALBUM_PATH = 'albumid';        /**     * Path to photo feeds on the Picasa server.     */    const PHOTO_PATH = 'photoid';        /**     * The path to the community search feed on the Picasa server.     */    const COMMUNITY_SEARCH_PATH = 'all';        /**     * The path to use for finding links to feeds within entries     */    const FEED_LINK_PATH = 'http://schemas.google.com/g/2005#feed';        /**     * The path to use for the determining type of an entry     */    const KIND_PATH = 'http://schemas.google.com/g/2005#kind';        public static $namespaces = array(            'gphoto' => 'http://schemas.google.com/photos/2007',            'photo' => 'http://www.pheed.com/pheed/',            'exif' => 'http://schemas.google.com/photos/exif/2007',            'georss' => 'http://www.georss.org/georss',            'gml' => 'http://www.opengis.net/gml',            'media' => 'http://search.yahoo.com/mrss/');    /**     * Create Zend_Gdata_Photos object     *      * @param Zend_Http_Client $client (optional) The HTTP client to use when      *          when communicating with the servers.     * @param string $applicationId The identity of the app in the form of Company-AppName-Version     */    public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0')    {        $this->registerPackage('Zend_Gdata_Photos');        $this->registerPackage('Zend_Gdata_Photos_Extension');        parent::__construct($client, $applicationId);        $this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME);    }    /**     * Retrieve a UserFeed containing AlbumEntries, PhotoEntries and      * TagEntries associated with a given user.     *     * @param string $userName The userName of interest     * @param mixed $location (optional) The location for the feed, as a URL      *          or Query. If not provided, a default URL will be used instead.     * @return Zend_Gdata_Photos_UserFeed     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     */    public function getUserFeed($userName = null, $location = null)    {        if ($userName !== null) {            $uri = self::PICASA_BASE_FEED_URI . '/' .                self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' .                $userName;        } else if ($location === null) {            $uri = self::PICASA_BASE_FEED_URI . '/' .                self::DEFAULT_PROJECTION . '/' . self::USER_PATH . '/' .                self::DEFAULT_USER;        } else if ($location instanceof Zend_Gdata_Photos_UserQuery) {            $location->setType('feed');            $uri = $location->getQueryUrl();        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }                return parent::getFeed($uri, 'Zend_Gdata_Photos_UserFeed');    }    /**     * Retreive AlbumFeed object containing multiple PhotoEntry or TagEntry     * objects.     *     * @param mixed $location (optional) The location for the feed, as a URL or Query.     * @return Zend_Gdata_Photos_AlbumFeed     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     */    public function getAlbumFeed($location = null)    {        if ($location === null) {            require_once 'Zend/Gdata/App/InvalidArgumentException.php';            throw new Zend_Gdata_App_InvalidArgumentException(                    'Location must not be null');        } else if ($location instanceof Zend_Gdata_Photos_UserQuery) {            $location->setType('feed');            $uri = $location->getQueryUrl();        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getFeed($uri, 'Zend_Gdata_Photos_AlbumFeed');    }    /**     * Retreive PhotoFeed object containing comments and tags associated      * with a given photo.     *     * @param mixed $location (optional) The location for the feed, as a URL     *          or Query. If not specified, the community search feed will     *          be returned instead.     * @return Zend_Gdata_Photos_PhotoFeed     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     */    public function getPhotoFeed($location = null)    {        if ($location === null) {            $uri = self::PICASA_BASE_FEED_URI . '/' .                self::DEFAULT_PROJECTION . '/' .                self::COMMUNITY_SEARCH_PATH;        } else if ($location instanceof Zend_Gdata_Photos_UserQuery) {            $location->setType('feed');            $uri = $location->getQueryUrl();        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getFeed($uri, 'Zend_Gdata_Photos_PhotoFeed');    }    /**     * Retreive a single UserEntry object.     *     * @param mixed $location The location for the feed, as a URL or Query.     * @return Zend_Gdata_Photos_UserEntry     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     */    public function getUserEntry($location)    {        if ($location === null) {            require_once 'Zend/Gdata/App/InvalidArgumentException.php';            throw new Zend_Gdata_App_InvalidArgumentException(                    'Location must not be null');        } else if ($location instanceof Zend_Gdata_Photos_UserQuery) {            $location->setType('entry');            $uri = $location->getQueryUrl();        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getEntry($uri, 'Zend_Gdata_Photos_UserEntry');    }    /**     * Retreive a single AlbumEntry object.     *     * @param mixed $location The location for the feed, as a URL or Query.     * @return Zend_Gdata_Photos_AlbumEntry     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     */    public function getAlbumEntry($location)    {        if ($location === null) {            require_once 'Zend/Gdata/App/InvalidArgumentException.php';            throw new Zend_Gdata_App_InvalidArgumentException(                    'Location must not be null');        } else if ($location instanceof Zend_Gdata_Photos_UserQuery) {            $location->setType('entry');            $uri = $location->getQueryUrl();        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getEntry($uri, 'Zend_Gdata_Photos_AlbumEntry');    }    /**     * Retreive a single PhotoEntry object.     *     * @param mixed $location The location for the feed, as a URL or Query.     * @return Zend_Gdata_Photos_PhotoEntry     * @throws Zend_Gdata_App_Exception     * @throws Zend_Gdata_App_HttpException     */    public function getPhotoEntry($location)    {        if ($location === null) {            require_once 'Zend/Gdata/App/InvalidArgumentException.php';            throw new Zend_Gdata_App_InvalidArgumentException(                    'Location must not be null');        } else if ($location instanceof Zend_Gdata_Photos_UserQuery) {

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?