当我尝试接收来自特定Facebook页面的所有数据(我有权访问,并保证从我的应用程序访问)时,它返回空数组。
但我在图形API资源管理器中使用相同的access_token,我可以看到所有内容。
任何想法为什么?!
这是我的代码:
<?php
include (APPPATH.'libraries/facebook/facebook.php');
class Fbpages_users extends Facebook {
public function Fbpages_users($pages) {
$ci =& get_instance();
$ci->config->load('facebook', TRUE);
$config = $ci->config->item('facebook');
$facebook = new Facebook(array(
'appId' => '***********',
'secret' => '**********',
));
parent::__construct($config);
for ($x=0; $x<count($pages); $x++) {
try {
$pageFeed = $this->api('/'.$pages[$x]['page_id'].'/feed?access_token='.$pages[$x]['access_token']);
$this->pagefeed = $pageFeed;
echo "<pre>";print_r($pageFeed); echo "</pre>";
for ($i=0;$i<count($pageFeed['data']);$i++) {
for ($z=0;$z<count($pageFeed['data'][$i]['likes']['data']);$z++) {
$query_fb_user_likes = $ci->db->query("
SELECT user_id,id_fb_pages,type FROM fb_users
where user_id like " . $pageFeed['data'][$i]['likes']['data'][$z]['id']
. " AND id_fb_pages like " . $pages[$x]['id_fb_pages']
. " AND type like 1
");
$verifica_query_likes = $query_fb_user_likes->result_array();
if ( (empty($verifica_query_likes)) AND ($pages[$x]['page_id'] != $pageFeed['data'][$i]['likes']['data'][$z]['id']) )
{
$likes = array(
'id_fb_pages' => $pages[$x]['id_fb_pages'],
'user_id' => $pageFeed['data'][$i]['likes']['data'][$z]['id'],
'type' => '1'
);
$ci->db->insert('fb_users', $likes);
}
}
for ($s=0;$s<count($pageFeed['data'][$i]['comments']['data']);$s++) {
$query_fb_user_comments = $ci->db->query("
SELECT user_id,id_fb_pages,type FROM fb_users
where user_id like " . $pageFeed['data'][$i]['comments']['data'][$s]['from']['id']
. " AND id_fb_pages like " . $pages[$x]['id_fb_pages']
. " AND type like 2
");
$verifica_query_comments = $query_fb_user_comments->result_array();
if ( (empty($verifica_query_comments)) AND ($pages[$x]['page_id'] != $pageFeed['data'][$i]['comments']['data'][$s]['from']['id']) )
{
$comments = array(
'id_fb_pages' => $pages[$x]['id_fb_pages'],
'user_id' => $pageFeed['data'][$i]['comments']['data'][$s]['from']['id'],
'type' => '2'
);
$ci->db->insert('fb_users', $comments);
}
}
}
$checked_pages_getusers = array(
'page_id' => $pages[$x]['page_id'],
'date_checked' => date ("Y-m-d H:i:s")
);
$ci->db->insert('checked_pages_getusers', $checked_pages_getusers);
} catch (FacebookApiException $e) {
error_log($e);
$error = array(
'logtype' => $pages[$x]['page_id'] . " - pages-users",
'date' => date ("Y-m-d H:i:s"),
'error' => "'" . $e . "'"
);
$ci->db->insert('error_log', $error);
}
}
//redirect('main/login');
}
}
?>