1

我正在运行这个简单的代码:

<?php
$keyword = 'iPhone';
$graph_url = "https://graph.facebook.com/search?";
$graph_url .= "&type=post";
$graph_url .= "&q=$keyword";
$results = file_get_contents( $graph_url );

$json = json_decode($results);

foreach($json->data as $show ) {
echo '<img src="'.$show->picture.'" alt="some_text"/><br />';
echo $show->from->name . "<br />";
echo $show->message . "<br />";
echo $show->created_time . "<br />";
echo "<hr>";
}
?>

它正在检索关键字“iPhone”的所有 Facebook 帖子,为什么有些内容是空的,Facebook 个人资料图片并未显示在所有帖子上,我将如何限制帖子。我该如何解决这个问题,有人指出我正确的方向吗?

4

1 回答 1

0
<?php
$keyword = 'iPhone';
$graph_url = "https://graph.facebook.com/search?";
$graph_url .= "&type=post";
$graph_url .= "&q=$keyword";

//添加这些行

 $graph_url .= "&fields=from,caption,created_time,picture";
 $graph_url .= "&limit=$number";

//

$results = file_get_contents($graph_url);

$json = json_decode($results);

foreach($json->data as $show ) {
echo '<img src="'.$show->picture.'" alt="some_text"/><br />';
echo $show->from->name . "<br />";
echo $show->caption. "<br />";
echo $show->created_time . "<br />";
echo "<hr>";
}
?>
于 2012-05-12T17:43:30.737 回答