Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $url_content = "https://www.googleapis.com/youtube/v3/videos?id=$video_ID&key=$api_key&part=statistics";
- $ch = curl_init();
- curl_setopt ($ch, CURLOPT_URL, $url_content);
- curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
- curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
- $contents = curl_exec($ch);
- $contents = file_get_contents("https://www.googleapis.com/youtube/v3/videos?id={$video_id}&key={$api_key}&part=snippet,statistics");
- $option = array(
- 'id' => $video_id,
- 'key' => $api_key,
- 'part' => 'statistics'
- );
- $url = "https://www.googleapis.com/youtube/v3/videos?".http_build_query($option, 'a', '&');
- $curl_handle=curl_init();
- curl_setopt($curl_handle, CURLOPT_URL,$url);
- curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
- curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
- $json_response = curl_exec($curl_handle);
- curl_close($curl_handle);
- Array
- (
- [0] => https://www.googleapis.com/youtube/v3/videos?id=VID&key=KEY&part=statistics
- [1] => stdClass Object
- (
- [error] => stdClass Object
- (
- [errors] => Array
- (
- [0] => stdClass Object
- (
- [domain] => usageLimits
- [reason] => ipRefererBlocked
- [message] => There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.
- [extendedHelp] => https://console.developers.google.com
- )
- )
- [code] => 403
- [message] => There is a per-IP or per-Referer restriction configured on your API key and the request does not match these restrictions. Please use the Google Developers Console to update your API key configuration if request from this IP or referer should be allowed.
- )
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement