<?php
header('Cache-Control: no-cache, must-revalidate');
header('Content-type: application/json');
$jsonData = json_decode(file_get_contents(urlencode('https://chart.googleapis.com/chart?cht=p3&chs=250x100&chd=t:60,40&chl=Hello|World&chof=json')));
echo $jsonData;
?>
Error: failed to open stream: No such file or directory in <b>C:\wamp\www\file.php
I want to print the result as a json string so i can handle it with jquery ajax. What am i missing? Thanks
You realise you have a space in your URL (results in a 400 from Google). Also, you don’t want to use
urlencode()here.I’d also hazard a guess that you don’t want to use
json_decode()as this will return an object or array.So, try this instead
To do what you’re attempting, please pay attention to this note in the manual
If you cannot configure your servers as such, you’ll want to check out cURL or the sockets extension