我遵循了为我创建的网站创建 facebook 帖子流的教程。流运行良好,现在已经完成了一段时间,但我刚刚再次检查了网站,现在它给了我一个错误。这是我正在使用的一些代码,主 foreach 循环似乎给了我一个错误:
我删除了一些 url 字符串
ini_set('display_errors', 1);
error_reporting(E_ALL);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/171614522965940/REMOVED SOME FOR SECURITY');
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$facebook_raw = curl_exec($ch);
$facebook_json = json_decode($facebook_raw);
$facebook_data = array();
foreach($facebook_json->data as $item) {
if($item->from->id == '658751738') {
$facebook_item = array(
'content' => $item->message,
'date' => strtotime($item->created_time),
'type' => 'facebook'
);
array_push($facebook_data, $facebook_item);
}
}
我得到的错误是:
Notice: Undefined property: stdClass::$data in /nfs/c09/h03/mnt/133481/domains/pass-out.org.uk/html/inc/fbfeed.php on line 16 Warning: Invalid argument supplied for foreach() in /nfs/c09/h03/mnt/133481/domains/pass-out.org.uk/html/inc/fbfeed.php on line 16