PHP Class Madcoda\Youtube\Youtube

Datei anzeigen Open project: madcoda/php-youtube-api

Public Properties

Property Type Description
$APIs array
$page_info array

Protected Properties

Property Type Description
$referer string
$youtube_key string The API Key

Public Methods

Method Description
__construct ( array $params = [] ) Constructor $youtube = new Youtube(array('key' => 'KEY HERE'))
_parse_url_path ( string $url ) : string Parse the input url string and return just the path part
_parse_url_query ( string $url ) : array Parse the input url string and return an array of query params
api_get ( $url, $params ) : mixed Using CURL to issue a GET request
decodeList ( string &$apiData ) : array Decode the response from youtube, extract the list of resource objects
decodeSingle ( string &$apiData ) : StdClass Decode the response from youtube, extract the single resource object.
getActivitiesByChannelId ( $channelId ) : array
getApi ( $name ) : mixed
getChannelById ( $id, $optionalParams = false ) : StdClass
getChannelByName ( $username, $optionalParams = false ) : StdClass
getChannelFromURL ( string $youtube_url ) : object Get the channel object by supplying the URL of the channel page
getPlaylistById ( $id ) : StdClass
getPlaylistItemsByPlaylistId ( $playlistId, $maxResults = 50 ) : array
getPlaylistItemsByPlaylistIdAdvanced ( $params, boolean | false $pageInfo = false ) : array
getPlaylistsByChannelId ( $channelId, array $optionalParams = [] ) : array
getVideoInfo ( $vId ) : StdClass
getVideosInfo ( $vIds ) : StdClass
paginateResults ( $params, $token = null ) : array Generic Search Paginator, use any parameters specified in the API reference and pass through nextPageToken as $token if set.
parseVIdFromURL ( string $youtube_url ) : string Parse a youtube URL to get the youtube Vid.
search ( $q, integer $maxResults = 10 ) : array Simple search interface, this search all stuffs and order by relevance
searchAdvanced ( $params, $pageInfo = false ) : array Generic Search interface, use any parameters specified in the API reference
searchChannelLiveStream ( $q, $channelId, $maxResults = 10, $order = null )
searchChannelVideos ( string $q, string $channelId, integer $maxResults = 10, string $order = null ) : object Search only videos in the channel
searchVideos ( string $q, integer $maxResults = 10, string $order = null ) : StdClass Search only videos
setAPIs ( array $APIs ) Override the API urls, so you can set them from a config
setApiKey ( $apiKey ) Update the API key, useful if you want to switch multiple keys to avoid quota problem
setReferer ( $referer )

Method Details

__construct() public method

Constructor $youtube = new Youtube(array('key' => 'KEY HERE'))
public __construct ( array $params = [] )
$params array

_parse_url_path() public static method

Parse the input url string and return just the path part
public static _parse_url_path ( string $url ) : string
$url string the URL
return string the path string

_parse_url_query() public static method

Parse the input url string and return an array of query params
public static _parse_url_query ( string $url ) : array
$url string the URL
return array array of query params

api_get() public method

Using CURL to issue a GET request
public api_get ( $url, $params ) : mixed
$url
$params
return mixed

decodeList() public method

Decode the response from youtube, extract the list of resource objects
public decodeList ( string &$apiData ) : array
$apiData string response string from youtube
return array Array of StdClass objects

decodeSingle() public method

(Don't use this to decode the response containing list of objects)
public decodeSingle ( string &$apiData ) : StdClass
$apiData string the api response from youtube
return StdClass an Youtube resource object

getActivitiesByChannelId() public method

public getActivitiesByChannelId ( $channelId ) : array
$channelId
return array

getApi() public method

public getApi ( $name ) : mixed
$name
return mixed

getChannelById() public method

public getChannelById ( $id, $optionalParams = false ) : StdClass
$id
return StdClass

getChannelByName() public method

public getChannelByName ( $username, $optionalParams = false ) : StdClass
$username
return StdClass

getChannelFromURL() public method

Get the channel object by supplying the URL of the channel page
public getChannelFromURL ( string $youtube_url ) : object
$youtube_url string
return object Channel object

getPlaylistById() public method

public getPlaylistById ( $id ) : StdClass
$id
return StdClass

getPlaylistItemsByPlaylistId() public method

public getPlaylistItemsByPlaylistId ( $playlistId, $maxResults = 50 ) : array
$playlistId
return array

getPlaylistItemsByPlaylistIdAdvanced() public method

public getPlaylistItemsByPlaylistIdAdvanced ( $params, boolean | false $pageInfo = false ) : array
$params
$pageInfo boolean | false
return array

getPlaylistsByChannelId() public method

public getPlaylistsByChannelId ( $channelId, array $optionalParams = [] ) : array
$channelId
$optionalParams array
return array

getVideoInfo() public method

public getVideoInfo ( $vId ) : StdClass
$vId
return StdClass

getVideosInfo() public method

public getVideosInfo ( $vIds ) : StdClass
$vIds
return StdClass

paginateResults() public method

Generic Search Paginator, use any parameters specified in the API reference and pass through nextPageToken as $token if set.
public paginateResults ( $params, $token = null ) : array
$params
$token
return array

parseVIdFromURL() public static method

Support both full URL (www.youtube.com) and short URL (youtu.be)
public static parseVIdFromURL ( string $youtube_url ) : string
$youtube_url string
return string Video Id

searchAdvanced() public method

Generic Search interface, use any parameters specified in the API reference
public searchAdvanced ( $params, $pageInfo = false ) : array
$params
$pageInfo
return array

searchChannelLiveStream() public method

public searchChannelLiveStream ( $q, $channelId, $maxResults = 10, $order = null )

searchChannelVideos() public method

Search only videos in the channel
public searchChannelVideos ( string $q, string $channelId, integer $maxResults = 10, string $order = null ) : object
$q string
$channelId string
$maxResults integer
$order string
return object

searchVideos() public method

Search only videos
public searchVideos ( string $q, integer $maxResults = 10, string $order = null ) : StdClass
$q string Query
$maxResults integer number of results to return
$order string Order by
return StdClass API results

setAPIs() public method

Override the API urls, so you can set them from a config
public setAPIs ( array $APIs )
$APIs array

setApiKey() public method

Update the API key, useful if you want to switch multiple keys to avoid quota problem
public setApiKey ( $apiKey )
$apiKey

setReferer() public method

public setReferer ( $referer )

Property Details

$APIs public_oe property

public array $APIs
return array

$page_info public_oe property

public array $page_info
return array

$referer protected_oe property

protected string $referer
return string

$youtube_key protected_oe property

The API Key
protected string $youtube_key
return string