Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. $url_content = "https://www.googleapis.com/youtube/v3/videos?id=$video_ID&key=$api_key&part=statistics";
  2. $ch = curl_init();
  3. curl_setopt ($ch, CURLOPT_URL, $url_content);
  4. curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
  5. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
  6. $contents = curl_exec($ch);
  7.  
  8. $contents = file_get_contents("https://www.googleapis.com/youtube/v3/videos?id={$video_id}&key={$api_key}&part=snippet,statistics");
  9.  
  10. $option = array(
  11. 'id' => $video_id,
  12. 'key' => $api_key,
  13. 'part' => 'statistics'
  14. );
  15. $url = "https://www.googleapis.com/youtube/v3/videos?".http_build_query($option, 'a', '&');
  16.  
  17.  
  18. $curl_handle=curl_init();
  19. curl_setopt($curl_handle, CURLOPT_URL,$url);
  20. curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
  21. curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
  22. 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');
  23. $json_response = curl_exec($curl_handle);
  24. curl_close($curl_handle);
  25.  
  26. Array
  27. (
  28. [0] => https://www.googleapis.com/youtube/v3/videos?id=VID&key=KEY&part=statistics
  29. [1] => stdClass Object
  30. (
  31. [error] => stdClass Object
  32. (
  33. [errors] => Array
  34. (
  35. [0] => stdClass Object
  36. (
  37. [domain] => usageLimits
  38. [reason] => ipRefererBlocked
  39. [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.
  40. [extendedHelp] => https://console.developers.google.com
  41. )
  42.  
  43. )
  44.  
  45. [code] => 403
  46. [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.
  47. )
  48.  
  49. )
  50.  
  51. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement