I am using Facebook open graph as json feed format to get the page name after I provide an access token in the URL.
here is my code:
$get_pages = file_get_contents("https://graph.facebook.com/me/accounts?access_token=".$_POST['access_token']);
$get_pages = json_decode($get_pages);
foreach($get_pages->data as $page){
echo $page[name];
}
I am trying to echo the name of the pages. The Json code that Facebook provide looks like this:
{
"data": [
{
"category": "website",
"name": "jjj",
"access_token": "jjj",
"id": "jjj",
"perms": [
"jjj",
"jjj",
"jjj",
"jjj",
"jjj",
"jjj"
]
},
{
"category": "Community",
"name": "ggg",
"access_token": "ggg",
"id": "ggg",
"perms": [
"ggg",
"ggg",
"ggg",
"ggg",
"ggg",
"ggg"
]
}
],
"paging": {
"next": "hhh"
}
}
I am getting this error:
catchable fatal error: object of class stdclass could not be converted to string in
with this line of code :$get_pages = json_decode($get_pages);
what am I doing wrong here ?
I solved it 🙂 I changed my code to this: