Magnet
Magnet

Reputation: 63

Youtube gdata curl error

By Using curl and json decode. I'm able to get the list of all youtube videos of a user. It works perfectly. Curl return NULL when server is busy. Please suggest me any solution for this problem

$curl = curl_init();
 curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
 curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0);
 curl_setopt($curl, CURLOPT_TIMEOUT, 60);
 curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
 curl_setopt($curl, CURLOPT_URL, 'http://gdata.youtube.com/feeds/api/users/USERNAME/uploads?v=2&alt=jsonc&max-results=30);
 $output = curl_exec($curl);
 curl_close($curl);
 $json = json_decode($output,true);

This is the code i'm using to get videos. It is returning NULL when server is Busy.

Upvotes: 0

Views: 227

Answers (1)

Anurag
Anurag

Reputation: 555

I suggest you should use developer key within your API call. Because i think this issue could be related to YouTube API quota error. You can get more information from this blog. You should pay attention to these quoted text:

The new quota system ties usage to a specific developer key; as long as your application includes a developer key along with your YouTube API requests, your requests will be less likely to be flagged for quota violations.

Upvotes: 1

Related Questions