Okay so what i am trying to achieve is use the youtube api to fetch some feeds. the feeds are json-c encoded. so i tried using file_get_contents method to convert the json feedurl into a string and json decode it. here is the code snippet:
$feedURL = "https://gdata.youtube.com/feeds/api/videos?q=surfing&v=2&alt=jsonc";
$json = file_get_contents($feedURL,0,null,null);
$result = json_decode($json, true);
echo $result;
$id = $result->{'data'}->{'items'}[0]->{'id'};
echo "The video id is: ".$id;
But i get this stupid error Warning: file_get_contents(https://gdata.youtube.com/feeds/api/videos?q=surfing&v=2&alt=jsonc) [function.file-get-contents]: failed to open stream: Connection refused in /opt/lampp/htdocs/date.php on line 13
Notice: Trying to get property of non-object in /opt/lampp/htdocs/date.php on line 16
Notice: Trying to get property of non-object in /opt/lampp/htdocs/date.php on line 16
Notice: Trying to get property of non-object in /opt/lampp/htdocs/date.php on line 16
The file’s name is date.php and i am running it on localhost on a linux machine behind a proxy server.
i think the connection refused thing suggests there might be an ip conflict or something. I don’t know. Could somebody please help me fix this?
You can use
curl