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
  • 139,522
  • 20
  • 204
  • 252
user1477332
  • 305
  • 1
  • 4
  • 16

0 Answers0