Hello I'm trying to get the FB feed from a user profile on my webpage: I'm using an app and the following is the code that I have tried:
<?php
//function to retrieve posts from facebook’s server
$token = 'https://graph.facebook.com/oauth/access_token?client_id=xxxxxx&client_secret=zzzyyyxxx&grant_type=client_credentials';
$token = file_get_contents($token);
function loadFB($fbID){
$url = "https://graph.facebook.com/".$fbID."/feed?limit=10";
$url.= '&access_token=xxxxxx|TLd1z0EZNH1SD1VfA';// *
$c = curl_init($url);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$page = json_decode(curl_exec($c));
var_dump($page);
curl_close($c);
if(isset($page->data)){
return $page->data;}else{echo "aabrakadaabra";}
}
$fbid = "myfbid";
date_default_timezone_set("America/Chicago");
$myPosts = loadFB($fbid);
foreach($myPosts as $dPost){
if($dPost->from->id==$fbid){
$dTime = strtotime($dPost->created_time);
$myTime=date("M d Y h:ia",$dTime);
?>
<ul>
<li><?php echo($dPost->message) . $myTime; ?></li>
</ul>
<?php
}
}
?>
Which is working fine, since I'm getting no error and to confirm the above I tried to see the feeds directly using the url below and it's returning empty data.
https://graph.facebook.com/myID/feed?&access_token=myToken
This is returning:
{
"data": [
]
}
I have tried several other answers posted on SO, but non helped.