I use below code to fetch an url, this works successfully, It returns an json data
$url = "https://graph.facebook.com/me?access_token=".$access_token;
function fetch_url($url){
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;
$java_url = new URL($url);
$java_bufferreader = new BufferedReader(new InputStreamReader($java_url->openStream()));
while (($line = $java_bufferreader->readLine()) != null) {
$content .= $line;
}
return $content;
}
// Sample usage:
$friends = fetch_url($url);
when i echo $friends I get the below json code,
{
"id": "100003185423323",
"name": "hnu Chid",
"first_name": "hnu",
"last_name": "Chid",
"link": "http://www.facebook.com/ilovaddddd",
"username": "ilddddd",
"education": [
{
"school": {
"id": "182225911846032",
"name": "Sunean"
},
"type": "High School"
},
{
"school": {
"id": "105504952817559",
"name": "Sathya University"
},
"type": "College"
}
],
"gender": "female",
"timezone": 5.5,
"locale": "en_US",
"verified": true,
"updated_time": "2012-09-18T18:37:57+0000"
}
I cant use json decode on GAE,When i try to json decode i get server error, is there any other way to parse it on php , please help me.
1. Make sure that json_decode exists (is enabled).
2. Use try catch to catch parsing errors.
3. Read more at http://php.net/manual/en/function.json-decode.php