jquery - Youtube API - retrieve single video info - JS works fine, PHP gives restriction error -


i wrote code

$url = 'https://www.googleapis.com/youtube/v3/videos?key=my_secret_key&part=snippet,statistics&id=yzj_ec8c5ng';  $curl = curl_init(); curl_setopt($curl, curlopt_url, $url); curl_setopt($curl, curlopt_returntransfer, true); curl_setopt($curl, curlopt_referer, 'http://niezaleznylublin.pl/'); curl_setopt($curl, curlopt_header, false); $json = curl_exec($curl); curl_close($curl);  $obiekt=json_decode($json); echo '<h1>'.$obiekt->items[0]->snippet->title.'</h1>'; echo '<img src="'.$obiekt->items[0]->snippet->thumbnails->standard->url.'"/>'; echo '<p>'.$obiekt->items[0]->snippet->description.'</p><br />'; echo '<h3>tagi:</h3>'; echo '<p>'; foreach ($obiekt->items[0]->snippet->tags $items)    {     echo $items.', '; }  echo'</p>'; echo $obiekt->items[0]->snippet->livebroadcastcontent;   echo '<br /><br /><br />';var_dump($obiekt); 

it works until youtube project open use site. when try add restriction site run script ... *niezaleznylublin.pl/**(one asterisk here) var_dump object contains data ...

object(stdclass)#1 (1) { ["error"]=> object(stdclass)#2 (3) { ["errors"]=> array(1) { [0]=> object(stdclass)#3 (4) { ["domain"]=> string(11) "usagelimits" ["reason"]=> string(16) "iprefererblocked" ["message"]=> string(254) "there per-ip or per-referer restriction configured on api key , request not match these restrictions. please use google developers console update api key configuration if request ip or referer should allowed." ["extendedhelp"]=> string(37) "https://console.developers.google.com" } } ["code"]=> int(403) ["message"]=> string(254) "there per-ip or per-referer restriction configured on api key , request not match these restrictions. please use google developers console update api key configuration if request ip or referer should allowed." } }    

funny thing when i'm trying jquery script site below working fine or without page restriction

http://salman-w.blogspot.com/2010/01/retrieve-youtube-video-title.html

lol odd. tried script today, havent change , works now. either kind of propagation involved here or indeed google guys watch youtube-api topics claim in center.

nevertheless responses.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -