⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 youtube.php

📁 Bug tracker, and reporter.
💻 PHP
📖 第 1 页 / 共 2 页
字号:
                    $location->setFeedType('most viewed');                }            }            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getFeed($uri, 'Zend_Gdata_YouTube_VideoFeed');    }    /**     * Retrieves a feed of recently featured videos.     *     * @param mixed $location (optional) The URL to query or a     *         Zend_Gdata_Query object from which a URL can be determined     * @return Zend_Gdata_YouTube_VideoFeed The feed of videos found at the      *         specified URL.     */    public function getRecentlyFeaturedVideoFeed($location = null)    {        if ($location == null) {            $uri = self::STANDARD_RECENTLY_FEATURED_URI;        } else if ($location instanceof Zend_Gdata_Query) {            if ($location instanceof Zend_Gdata_YouTube_VideoQuery) {                if (!isset($location->url)) {                    $location->setFeedType('recently featured');                }            }            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getFeed($uri, 'Zend_Gdata_YouTube_VideoFeed');    }    /**     * Retrieves a feed of videos recently featured for mobile devices.     * These videos will have RTSP links in the $entry->mediaGroup->content     *     * @param mixed $location (optional) The URL to query or a     *         Zend_Gdata_Query object from which a URL can be determined     * @return Zend_Gdata_YouTube_VideoFeed The feed of videos found at the      *         specified URL.     */    public function getWatchOnMobileVideoFeed($location = null)    {        if ($location == null) {            $uri = self::STANDARD_WATCH_ON_MOBILE_URI;        } else if ($location instanceof Zend_Gdata_Query) {            if ($location instanceof Zend_Gdata_YouTube_VideoQuery) {                if (!isset($location->url)) {                    $location->setFeedType('watch on mobile');                }            }            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getFeed($uri, 'Zend_Gdata_YouTube_VideoFeed');    }    /**     * Retrieves a feed which lists a user's playlist     *     * @param string $user (optional) The username of interest     * @param mixed $location (optional) The URL to query or a     *         Zend_Gdata_Query object from which a URL can be determined     * @return Zend_Gdata_YouTube_PlaylistListFeed The feed of playlists      */    public function getPlaylistListFeed($user = null, $location = null)    {        if ($user !== null) {            $uri = 'http://gdata.youtube.com/feeds/users/' . $user . '/playlists';        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getFeed($uri, 'Zend_Gdata_YouTube_PlaylistListFeed');    }    /**     * Retrieves a feed of videos in a particular playlist     *     * @param mixed $location (optional) The URL to query or a     *         Zend_Gdata_Query object from which a URL can be determined     * @return Zend_Gdata_YouTube_PlaylistVideoFeed The feed of videos found at     *         the specified URL.     */    public function getPlaylistVideoFeed($location)    {        if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getFeed($uri, 'Zend_Gdata_YouTube_PlaylistVideoFeed');    }    /**     * Retrieves a feed of a user's subscriptions     *     * @param string $user (optional) The username of interest     * @param mixed $location (optional) The URL to query or a     *         Zend_Gdata_Query object from which a URL can be determined     * @return Zend_Gdata_YouTube_SubscriptionListFeed The feed of subscriptions      */    public function getSubscriptionFeed($user = null, $location = null)    {        if ($user !== null) {            $uri = 'http://gdata.youtube.com/feeds/users/' . $user . '/subscriptions';        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getFeed($uri, 'Zend_Gdata_YouTube_SubscriptionFeed');    }    /**     * Retrieves a feed of a user's contacts     *     * @param string $user (optional) The username of interest     * @param mixed $location (optional) The URL to query or a     *         Zend_Gdata_Query object from which a URL can be determined     * @return Zend_Gdata_YouTube_ContactFeed The feed of contacts      */    public function getContactFeed($user = null, $location = null)    {        if ($user !== null) {            $uri = 'http://gdata.youtube.com/feeds/users/' . $user . '/contacts';        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getFeed($uri, 'Zend_Gdata_YouTube_ContactFeed');    }    /**     * Retrieves a user's uploads     *     * @param string $user (optional) The username of interest     * @param mixed $location (optional) The URL to query or a     *         Zend_Gdata_Query object from which a URL can be determined     * @return Zend_Gdata_YouTube_VideoFeed The videos uploaded by the user     */    public function getUserUploads($user = null, $location = null)    {        if ($user !== null) {            $uri = 'http://gdata.youtube.com/feeds/users/' . $user . '/' .                   self::UPLOADS_URI_SUFFIX;        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getFeed($uri, 'Zend_Gdata_YouTube_VideoFeed');    }    /**     * Retrieves a user's favorites     *     * @param string $user (optional) The username of interest     * @param mixed $location (optional) The URL to query or a     *         Zend_Gdata_Query object from which a URL can be determined     * @return Zend_Gdata_YouTube_VideoFeed The videos favorited by the user     */    public function getUserFavorites($user = null, $location = null)    {        if ($user !== null) {            $uri = 'http://gdata.youtube.com/feeds/users/' . $user . '/' .                   self::FAVORITES_URI_SUFFIX;        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getFeed($uri, 'Zend_Gdata_YouTube_VideoFeed');    }    /**     * Retrieves a user's profile as an entry      *     * @param string $user (optional) The username of interest     * @param mixed $location (optional) The URL to query or a     *         Zend_Gdata_Query object from which a URL can be determined     * @return Zend_Gdata_YouTube_UserProfileEntry The user profile entry     */    public function getUserProfile($user = null, $location = null)    {        if ($user !== null) {            $uri = 'http://gdata.youtube.com/feeds/users/' . $user;        } else if ($location instanceof Zend_Gdata_Query) {            $uri = $location->getQueryUrl();        } else {            $uri = $location;        }        return parent::getEntry($uri, 'Zend_Gdata_YouTube_UserProfileEntry');    }    /**     * Helper function for parsing a YouTube token response     *      * @param string $response The service response     * @return array An array containing the token and URL     */    public static function parseFormUploadTokenResponse($response)    {        // Load the feed as an XML DOMDocument object        @ini_set('track_errors', 1);        $doc = new DOMDocument();        $success = @$doc->loadXML($response);        @ini_restore('track_errors');        if (!$success) {            require_once 'Zend/Gdata/App/Exception.php';            throw new Zend_Gdata_App_Exception("Zend_Gdata_YouTube::parseFormUploadTokenResponse - " .                                               "DOMDocument cannot parse XML: $php_errormsg");        }        $responseElement = $doc->getElementsByTagName('response')->item(0);        $urlText = null;        $tokenText = null;        if ($responseElement != null) {            $urlElement = $responseElement->getElementsByTagName('url')->item(0);            $tokenElement = $responseElement->getElementsByTagName('token')->item(0);            if ($urlElement && $urlElement->hasChildNodes() &&                $tokenElement && $tokenElement->hasChildNodes()) {                $urlText = $urlElement->firstChild->nodeValue;                $tokenText = $tokenElement->firstChild->nodeValue;            }        }        if ($tokenText != null && $urlText != null) {            return array('token' => $tokenText, 'url' => $urlText);        } else {            require_once 'Zend/Gdata/App/Exception.php';            throw new Zend_Gdata_App_Exception("form upload token not found in response");        }    }    /**     * Retrieves a YouTube token     *      * @param Zend_Gdata_YouTube_VideoEntry $videoEntry The video entry     * @param string $url The location as a string URL     * @return array An array containing a token and URL     */    public function getFormUploadToken($videoEntry, $url='http://gdata.youtube.com/action/GetUploadToken')    {        if ($url != null && is_string($url)) {            // $response is a Zend_Http_response object            $response = $this->post($videoEntry, $url);            return self::parseFormUploadTokenResponse($response->getBody());         } else {            throw new Zend_Gdata_App_Exception('url must be provided as a string URL');        }    }}

⌨️ 快捷键说明

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