Gdata/YouTube.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
- copyright
- Copyright (c) 2005-2011 Zend Technologies USA Inc.
(http://www.zend.com)
- license
- New
BSD License
- package
- Zend_Gdata
- subpackage
- YouTube
- version
- $Id: YouTube.php 23775 2011-03-01 17:25:24Z ralph $
Service class for interacting with the
YouTube Data API.
As the Google data API protocol is based upon the Atom Publishing
Protocol (APP), Gdata functionality extends the appropriate
Zend_Gdata_App classes
- Extends from
- \Zend_Gdata_Media
- category
- Zend
- copyright
- Copyright (c) 2005-2011 Zend Technologies USA Inc.
(http://www.zend.com)
- license
- New
BSD License
- link
- http://code.google.com/apis/youtube/
- package
- Zend_Gdata
- subpackage
- YouTube
Constants
Properties



array $namespaces=
'array'
static
Namespaces used for Zend_Gdata_YouTube
Default valuearray
Details
- Type
- array
Methods



__call( string $method, array $args ) : void
Provides a magic factory method to
instantiate new objects with shorter syntax than would otherwise be
required by the Zend Framework naming conventions. For instance, to
construct a new Zend_Gdata_Calendar_Extension_Color, a developer simply
needs to do $gCal->newColor(). For this magic constructor, packages are
searched in the same order as which they appear in the
$_registeredPackages array
Inherited from: \Zend_Gdata_App::__call()
Parameters
Name |
Type |
Description |
$method |
string |
The method name being called |
$args |
array |
The arguments passed to the call |
Throws



__construct( \Zend_Http_Client $client
= null, string $applicationId = MyCompany-MyApp-1.0, string $clientId =
null, string $developerKey = null ) : void
Create Zend_Gdata_YouTube object
Parameters
Name |
Type |
Description |
$client |
\Zend_Http_Client |
(optional) The HTTP client to use when when communicating with
the Google servers.
|
$applicationId |
string |
The identity of the app in the form of Company-AppName-Version
|
$clientId |
string |
The clientId issued by the YouTube dashboard |
$developerKey |
string |
The developerKey issued by the YouTube dashboard |



get( string $uri, array $extraHeaders = array
) : \Zend_Http_Response
Parameters
Name |
Type |
Description |
$uri |
string |
GET URI |
$extraHeaders |
array |
Extra headers to add to the request, as an array of
string-based key/value pairs.
|
Returns
Throws



getActivityForUser( $username ) : \Zend_Gdata_YouTube_ActivityFeed
Retrieves the activity feed for users
Parameters
Name |
Type |
Description |
$username |
|
|
Returns
Throws



getContactFeed( string $user = null, mixed $location =
null ) : \Zend_Gdata_YouTube_ContactFeed
Retrieves a feed of a user's contacts
Parameters
Name |
Type |
Description |
$user |
string |
(optional) The username of interest
|
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns



getFormUploadToken( \Zend_Gdata_YouTube_VideoEntry $videoEntry,
string $url = http://gdata.youtube.com/action/GetUploadToken ) : array
Retrieves a YouTube token
Parameters
Returns
Type |
Description |
array |
An array containing a token and URL |
Throws



getFullVideoEntry( $videoId ) : \Zend_Gdata_YouTube_VideoEntry|null
Retrieves a video entry from the user's
upload feed.
Parameters
Name |
Type |
Description |
$videoId |
|
|
Returns
Type |
Description |
\Zend_Gdata_YouTube_VideoEntrynull |
The video entry to be retrieved, or null if it was not found
or the user requesting it did not have the appropriate permissions. |
Throws



getMostViewedVideoFeed( mixed $location = null ) : \Zend_Gdata_YouTube_VideoFeed
Retrieves a feed of the most viewed
videos.
Parameters
Name |
Type |
Description |
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns



getPlaylistListFeed( string $user = null, mixed $location =
null ) : \Zend_Gdata_YouTube_PlaylistListFeed
Retrieves a feed which lists a user's
playlist
Parameters
Name |
Type |
Description |
$user |
string |
(optional) The username of interest
|
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns



getPlaylistVideoFeed( mixed $location ) : \Zend_Gdata_YouTube_PlaylistVideoFeed
Retrieves a feed of videos in a
particular playlist
Parameters
Name |
Type |
Description |
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns



getRecentlyFeaturedVideoFeed( mixed $location = null ) : \Zend_Gdata_YouTube_VideoFeed
Retrieves a feed of recently featured
videos.
Parameters
Name |
Type |
Description |
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns



getRelatedVideoFeed( string $videoId = null, mixed $location
= null ) : \Zend_Gdata_YouTube_VideoFeed
Retrieves a feed of videos related to
the specified video ID.
Parameters
Name |
Type |
Description |
$videoId |
string |
The videoId of interest |
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns



getSubscriptionFeed( string $user = null, mixed $location =
null ) : \Zend_Gdata_YouTube_SubscriptionListFeed
Retrieves a feed of a user's
subscriptions
Parameters
Name |
Type |
Description |
$user |
string |
(optional) The username of interest
|
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns
Type |
Description |
\Zend_Gdata_YouTube_SubscriptionListFeed |
The feed of subscriptions |



getTopRatedVideoFeed( mixed $location = null ) : \Zend_Gdata_YouTube_CommentFeed
Retrieves a feed of comments related to
the specified video ID.
Parameters
Name |
Type |
Description |
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns



getUserFavorites( string $user = null, mixed $location =
null ) : \Zend_Gdata_YouTube_VideoFeed
Retrieves a user's favorites
Parameters
Name |
Type |
Description |
$user |
string |
(optional) The username of interest
|
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns



getUserProfile( string $user = null, mixed $location =
null ) : \Zend_Gdata_YouTube_UserProfileEntry
Retrieves a user's profile as an entry
Parameters
Name |
Type |
Description |
$user |
string |
(optional) The username of interest
|
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns



getUserUploads( string $user = null, mixed $location =
null ) : \Zend_Gdata_YouTube_VideoFeed
Retrieves a user's uploads
Parameters
Name |
Type |
Description |
$user |
string |
(optional) The username of interest
|
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns



getVideoCommentFeed( string $videoId = null, mixed $location
= null ) : \Zend_Gdata_YouTube_CommentFeed
Retrieves a feed of comments related to
the specified video ID.
Parameters
Name |
Type |
Description |
$videoId |
string |
The videoId of interest |
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns



getVideoEntry( mixed $videoId = null, mixed $location =
null, boolean $fullEntry = false ) : \Zend_Gdata_YouTube_VideoEntry
Retrieves a specific video entry.
Parameters
Name |
Type |
Description |
$videoId |
mixed |
The ID of the video to retrieve. |
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined.
|
$fullEntry |
boolean |
(optional) Retrieve the full metadata for the entry. Only
possible if entry belongs to currently authenticated user. An
exception will be thrown otherwise.
|
Returns
Throws



getVideoFeed( mixed $location = null ) : \Zend_Gdata_YouTube_VideoFeed
Retrieves a feed of videos.
Parameters
Name |
Type |
Description |
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns



getVideoResponseFeed( string $videoId = null, mixed $location
= null ) : \Zend_Gdata_YouTube_VideoFeed
Retrieves a feed of video responses
related to the specified video ID.
Parameters
Name |
Type |
Description |
$videoId |
string |
The videoId of interest |
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns



getWatchOnMobileVideoFeed( mixed $location = null ) : \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
Parameters
Name |
Type |
Description |
$location |
mixed |
(optional) The URL to query or a Zend_Gdata_Query object from
which a URL can be determined
|
Returns



importUrl( string $url, string $className =
Zend_Gdata_App_Feed, array $extraHeaders = array ) : string|\Zend_Gdata_App_Feed
Parameters
Name |
Type |
Description |
$url |
string |
The URL to import |
$className |
string |
The class which is used as the return type |
$extraHeaders |
array |
Extra headers to add to the request, as an array of
string-based key/value pairs.
|
Returns
Type |
Description |
string\Zend_Gdata_App_Feed
|
Returns string only if the object mapping has been disabled
explicitly by passing false to the useObjectMapping() function. |
Throws



insertEntry( mixed $data, string $uri,
string $className = Zend_Gdata_App_Entry, array $extraHeaders = array )
: \Zend_Gdata_App_Entry
Parameters
Name |
Type |
Description |
$data |
mixed |
The Zend_Gdata_App_Entry or XML to post |
$uri |
string |
POST URI |
$className |
string |
The class of entry to be returned. |
$extraHeaders |
array |
Extra headers to add to the request, as an array of
string-based key/value pairs.
|
Returns



parseFormUploadTokenResponse( string $response ) : array
static
Helper function for parsing a YouTube
token response
Parameters
Name |
Type |
Description |
$response |
string |
The service response |
Returns
Type |
Description |
array |
An array containing the token and URL |
Throws



performHttpRequest( string $method, string $url,
array $headers = array, string $body = null, string $contentType = null,
int $remainingRedirects = null ) : \Zend_Http_Response
Overrides the definition in the parent (Zend_Gdata_App) and uses
the Zend_Gdata_HttpClient functionality to filter the HTTP requests and
responses.
Parameters
Name |
Type |
Description |
$method |
string |
The HTTP method for the request - 'GET', 'POST', 'PUT',
'DELETE'
|
$url |
string |
The URL to which this request is being performed, or null if
found in $data
|
$headers |
array |
An associative array of HTTP headers for this
request |
$body |
string |
The body of the HTTP request |
$contentType |
string |
The value for the content type of the request body |
$remainingRedirects |
int |
Number of redirects to follow if requests results in
one |
Returns



post( mixed $data, string $uri = null,
$remainingRedirects = null, string $contentType = null,
array $extraHeaders = null ) : \Zend_Http_Response
Parameters
Name |
Type |
Description |
$data |
mixed |
The Zend_Gdata_App_Entry or XML to post |
$uri |
string |
POST URI |
$remainingRedirects |
|
|
$contentType |
string |
Content-type of the data
|
$extraHeaders |
array |
Extra headers to add to the request, as an array of
string-based key/value pairs.
|
Returns
Throws



prepareRequest( string $method, string $url = null,
array $headers = array, mixed $data = null, string $contentTypeOverride
= null ) : array
- Checks the $data element and, if it's an entry, extracts the
XML, multipart data, edit link (PUT,DELETE), etc.
- If $data is a string, sets the default content-type header as
'application/atom+xml' if it's not already been set.
- Adds a x-http-method override header and changes the HTTP
method to 'POST' if necessary as per getHttpMethodOverride()
Parameters
Name |
Type |
Description |
$method |
string |
The HTTP method for the request - 'GET', 'POST', 'PUT',
'DELETE'
|
$url |
string |
The URL to which this request is being performed, or null if
found in $data
|
$headers |
array |
An associative array of HTTP headers for this
request |
$data |
mixed |
The Zend_Gdata_App_Entry or XML for the body of the
request |
$contentTypeOverride |
string |
The override value for the content type of the
request body |
Returns
Type |
Description |
array |
An associative array containing the determined 'method',
'url', 'data', 'headers', 'contentType' |



put( mixed $data, string $uri = null,
$remainingRedirects = null, string $contentType = null,
array $extraHeaders = null ) : \Zend_Http_Response
Parameters
Name |
Type |
Description |
$data |
mixed |
The Zend_Gdata_App_Entry or XML to post |
$uri |
string |
PUT URI |
$remainingRedirects |
|
|
$contentType |
string |
Content-type of the data
|
$extraHeaders |
array |
Extra headers to add to the request, as an array of
string-based key/value pairs.
|
Returns
Throws



registerPackage( string $name ) : void
This array is searched when using the magic __call method below
to instantiante new objects.
Parameters
Name |
Type |
Description |
$name |
string |
The name of the package (eg Zend_Gdata_App)
|



sendVideoMessage( string $body, \Zend_Gdata_YouTube_VideoEntry $videoEntry
= null, string $videoId = null, string $recipientUserName ) : \Zend_Gdata_YouTube_InboxEntry|null
Note: Either a Zend_Gdata_YouTube_VideoEntry or a valid video ID
must be provided.
Parameters
Name |
Type |
Description |
$body |
string |
The body of the message |
$videoEntry |
\Zend_Gdata_YouTube_VideoEntry |
(optional) The video entry to send
|
$videoId |
string |
The id of the video to send |
$recipientUserName |
string |
The username of the recipient |
Returns
Throws



setHttpClient( \Zend_Http_Client $client,
$applicationId = MyCompany-MyApp-1.0, $clientId = null, $developerKey
= null ) : \Zend_Gdata_App
Set the Zend_Http_Client object used
for communication
Parameters
Name |
Type |
Description |
$client |
\Zend_Http_Client |
The client to use for communication |
$applicationId |
|
|
$clientId |
|
|
$developerKey |
|
|
Returns
Throws



setMinorProtocolVersion( \(int|\NULL) $value ) : void
Set the minor protocol version that
should be used. If set to NULL, no minor protocol version will be sent
to the server. Values < 0 will cause a
Zend_Gdata_App_InvalidArgumentException to be thrown.
Inherited from: \Zend_Gdata_App::setMinorProtocolVersion()
Parameters
Name |
Type |
Description |
$value |
\(int|\NULL) |
The minor protocol version to use. |
Throws
Details
- see
- \_minorProtocolVersion



updateEntry( mixed $data, string|null $uri = null,
string|null $className = null, array $extraHeaders = array ) : \Zend_Gdata_App_Entry
Parameters
Name |
Type |
Description |
$data |
mixed |
Zend_Gdata_App_Entry or XML (w/ID and link rel='edit')
|
$uri |
string|null |
The URI to send requests to, or null if $data contains the URI.
|
$className |
string|null |
The name of the class that should be deserialized from the
server response. If null, then 'Zend_Gdata_App_Entry' will be used.
|
$extraHeaders |
array |
Extra headers to add to the request, as an array of
string-based key/value pairs.
|
Returns
Throws