0

i am working on a project ... i want to get file content of youtube url i used this code :

$url   = 'http://gdata.youtube.com/feeds/api/videos/'. urlencode($name).'?alt=json';

$json = file_get_contents($url);

but if the video does not exist or invalid ... i have error in this line

$json = file_get_contents($url);

Warning: file_get_contents(http://gdata.youtube.com/feeds/api/videos/sadsad?alt=json): failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request

i want if the user post does not exist video ... link appears or anything happened but i want this warning to disppear

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
user1477332
  • 325
  • 2
  • 4
  • 20

0 Answers0