slideshare.php

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

PHP
611
字号
<?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_Service * @subpackage SlideShare * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license    http://framework.zend.com/license/new-bsd     New BSD License * @version    $Id: SlideShare.php 8260 2008-02-21 21:35:56Z darby $ * @author     John Coggeshall <john@zend.com> *//** * Zend_Http_Client */require_once 'Zend/Http/Client.php';/** * Zend_Cache */require_once 'Zend/Cache.php';/** * Zend_Service_SlideShare_Exception */require_once 'Zend/Service/SlideShare/Exception.php';/** * Zend_Service_SlideShare_SlideShow */require_once 'Zend/Service/SlideShare/SlideShow.php';/** * The Zend_Service_SlideShare component is used to interface with the * slideshare.net web server to retrieve slide shows hosted on the web site for * display or other processing. * * @category   Zend * @package    Zend_Service * @subpackage SlideShare * @throws     Zend_Service_SlideShare_Exception * @copyright  Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com) * @license    http://framework.zend.com/license/new-bsd     New BSD License * @author     John Coggeshall <john@zend.com> */class Zend_Service_SlideShare{    /**     * Web service result code mapping     */    const SERVICE_ERROR_BAD_APIKEY       = 1;    const SERVICE_ERROR_BAD_AUTH         = 2;    const SERVICE_ERROR_MISSING_TITLE    = 3;    const SERVICE_ERROR_MISSING_FILE     = 4;    const SERVICE_ERROR_EMPTY_TITLE      = 5;    const SERVICE_ERROR_NOT_SOURCEOBJ    = 6;    const SERVICE_ERROR_INVALID_EXT      = 7;    const SERVICE_ERROR_FILE_TOO_BIG     = 8;    const SERVICE_ERROR_SHOW_NOT_FOUND   = 9;    const SERVICE_ERROR_USER_NOT_FOUND   = 10;    const SERVICE_ERROR_GROUP_NOT_FOUND  = 11;    const SERVICE_ERROR_MISSING_TAG      = 12;    const SERVICE_ERROR_DAILY_LIMIT      = 99;    const SERVICE_ERROR_ACCOUNT_BLOCKED  = 100;    /**     * Slide share Web service communication URIs     */    const SERVICE_UPLOAD_URI                  = 'http://www.slideshare.net/api/1/upload_slideshow';    const SERVICE_GET_SHOW_URI                = 'http://www.slideshare.net/api/1/get_slideshow';    const SERVICE_GET_SHOW_BY_USER_URI        = 'http://www.slideshare.net/api/1/get_slideshow_by_user';    const SERVICE_GET_SHOW_BY_TAG_URI         = 'http://www.slideshare.net/api/1/get_slideshow_by_tag';    const SERVICE_GET_SHOW_BY_GROUP_URI       = 'http://www.slideshare.net/api/1/get_slideshows_from_group';    /**     * The MIME type of Slideshow files     *     */    const POWERPOINT_MIME_TYPE    = "application/vnd.ms-powerpoint";    /**     * The API key to use in requests     *     * @var string The API key     */    protected $_apiKey;    /**     * The shared secret to use in requests     *     * @var string the Shared secret     */    protected $_sharedSecret;    /**     * The username to use in requests     *     * @var string the username     */    protected $_username;    /**     * The password to use in requests     *     * @var string the password     */    protected $_password;    /**     * The HTTP Client object to use to perform requests     *     * @var Zend_Http_Client     */    protected $_httpclient;    /**     * The Cache object to use to perform caching     *     * @var Zend_Cache_Core     */    protected $_cacheobject;    /**     * Sets the Zend_Http_Client object to use in requests. If not provided a default will     * be used.     *     * @param Zend_Http_Client $client The HTTP client instance to use     * @return Zend_Service_SlideShare     */    public function setHttpClient(Zend_Http_Client $client)    {        $this->_httpclient = $client;        return $this;    }    /**     * Returns the instance of the Zend_Http_Client which will be used. Creates an instance     * of Zend_Http_Client if no previous client was set.     *     * @return Zend_Http_Client The HTTP client which will be used     */    public function getHttpClient()    {        if(!($this->_httpclient instanceof Zend_Http_Client)) {            $client = new Zend_Http_Client();            $client->setConfig(array('maxredirects' => 2,                                     'timeout' => 5));            $this->setHttpClient($client);        }        $this->_httpclient->resetParameters();        return $this->_httpclient;    }    /**     * Sets the Zend_Cache object to use to cache the results of API queries     *     * @param Zend_Cache_Core $cacheobject The Zend_Cache object used     * @return Zend_Service_SlideShare     */    public function setCacheObject(Zend_Cache_Core $cacheobject)    {        $this->_cacheobject = $cacheobject;        return $this;    }    /**     * Gets the Zend_Cache object which will be used to cache API queries. If no cache object     * was previously set the the default will be used (Filesystem caching in /tmp with a life     * time of 43200 seconds)     *     * @return Zend_Cache_Core The object used in caching     */    public function getCacheObject()    {        if(!($this->_cacheobject instanceof Zend_Cache_Core)) {            $cache = Zend_Cache::factory('Core', 'File', array('lifetime' => 43200,                                                               'automatic_serialization' => true),                                                         array('cache_dir' => '/tmp'));            $this->setCacheObject($cache);        }        return $this->_cacheobject;    }    /**     * Returns the user name used for API calls     *     * @return string The username     */    public function getUserName()    {        return $this->_username;    }    /**     * Sets the user name to use for API calls     *     * @param string $un The username to use     * @return Zend_Service_SlideShare     */    public function setUserName($un)    {        $this->_username = $un;        return $this;    }    /**     * Gets the password to use in API calls     *     * @return string the password to use in API calls     */    public function getPassword()    {        return $this->_password;    }    /**     * Sets the password to use in API calls     *     * @param string $pw The password to use     * @return Zend_Service_SlideShare     */    public function setPassword($pw)    {        $this->_password = (string)$pw;        return $this;    }    /**     * Gets the API key to be used in making API calls     *     * @return string the API Key     */    public function getApiKey()    {        return $this->_apiKey;    }    /**     * Sets the API key to be used in making API calls     *     * @param string $key The API key to use     * @return Zend_Service_SlideShare     */    public function setApiKey($key)    {        $this->_apiKey = (string)$key;        return $this;    }    /**     * Gets the shared secret used in making API calls     *     * @return string the Shared secret     */    public function getSharedSecret()    {        return $this->_sharedSecret;    }    /**     * Sets the shared secret used in making API calls     *     * @param string $secret the shared secret     * @return Zend_Service_SlideShare     */    public function setSharedSecret($secret)    {        $this->_sharedSecret = (string)$secret;        return $this;    }    /**     * The Constructor     *     * @param string $apikey The API key     * @param string $sharedSecret The shared secret     * @param string $username The username     * @param string $password The password     */    public function __construct($apikey, $sharedSecret, $username = null, $password = null)    {        $this->setApiKey($apikey)             ->setSharedSecret($sharedSecret)             ->setUserName($username)             ->setPassword($password);        $this->_httpclient = new Zend_Http_Client();    }

⌨️ 快捷键说明

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