fetch Youtube subscribers count by JSON API in PHP -


i want subscriber count value json file: http://gdata.youtube.com/feeds/api/users/googlechrome?v=2&alt=json

this did it's not working.

$youtube_url = json_decode( file_get_contents( 'http://gdata.youtube.com/feeds/api/users/googlechrome?v=2&alt=json' ), true ); $youtube_data = $youtube_url['entry']['yt$statistics']['subscribercount']; 

php code:

function get_yt_subs($username) {   $xmldata = file_get_contents('http://gdata.youtube.com/feeds/api/users/' . strtolower($username));  $xmldata = str_replace('yt:', 'yt', $xmldata);   $xml = new simplexmlelement($xmldata);   $subs = $xml->ytstatistics['subscribercount'];   return($subs);   }   

example of usage: php code:

get_yt_subs('3moeslam') 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -