将Facebook照片添加到自定义Feed


Adding Facebook Photos to Custom Feed

我正试图将Facebook feed添加到一个网站,一切都在工作,除了我不能让它显示照片状态。这是我目前所掌握的:

$page_id = 'xxxxxxxxx';
$access_token = 'xxxxxxx|xxxxxxxxxx';
//Get the JSON
$json_object = @file_get_contents('https://graph.facebook.com/' . $page_id . 
'/posts?access_token=' . $access_token);
//Interpret data
$fbdata = json_decode($json_object);

$i = 1;
foreach ($fbdata->data as $post )
{
if($i < 2){
$posts .= '<p><a href="' . $post->link . '">' . $post->story . '</a></p>';
$posts .= '<p><a href="' . $post->link . '">' . $post->message . '</a></p>';
$posts .= '<p>' . $post->description . '</p>';
$posts .= '<img src="'.$post->picture.'">';
}
$i++;
}
//Display the posts
echo $posts;
?>

所以,为了显示图片,与您的帖子:

$page_id = 'xxxxxxxxx';
$access_token = 'xxxxxxx|xxxxxxxxxx';
//Get the JSON
$json_object = @file_get_contents('https://graph.facebook.com/' . $page_id . 
'/posts?access_token=' . $access_token . '&fields=id,link,message,picture,description,story');
//Interpret data
$fbdata = json_decode($json_object);
$i = 1;
foreach ($fbdata->data as $post )
{
if($i < 2){
//$posts .= '<p><a href="' . $post->link . '">' . $post->story . '</a></p>';
$posts .= '<p><a href="' . $post->link . '">' . $post->message . '</a><img src="'.$post->picture.'"></p>';
//$posts .= '<p>' . $post->description . '</p>';
//$posts .= '<br />';
}
$i++;
}
//Display the posts
echo $posts;

如果你想要照片

$photo = $news->picture;
$content .= "<img src='{$photo}'/>"; 

添加此代码