特定の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');
}
}
?>