开发者

Unable to retrieve post impressions with Facebook FQL

I'm trying to query FB for a Page Stream using FQL in PHP, and I get all the data except impressions. The FB_ACCESS_TOKEN used is the OAuth token for my FB App, where I have granted the following scope: offline_access,manage_pages,email,read_insights,sms,publish_stream

Code example:

$this->fb->api(array(
  "method" => "fql.multiquery",
  "queries" => json_encode(array(
    "post" => "SELECT post_id, source_id, updated_time, created_time, actor_id, 
                      message, attachment, impressions, likes, privacy, 
                      permalink, comments 
               FROM stream WHERE source_id='".$source_id."' 
                           AND created_time > '".$date_updated."'",
    "comment" => "SELECT post_id, fromid, time, text, id, likes, object_id 
                  FROM comment WHERE post_id IN (SELECT post_id FROM #post) 
                               AND time> '".$date_updated."'"
  )), access_token" => FB_ACCESS_TOKEN
));

Here is the example output:

[...]
[0] => Array(
  [post_id] => 107112482661088_236459409726394
  [source_id] => 107112482661088
  [updated_time] => 1312884237
  [created_time] => 1312884237
  [actor_id] => 608795063
  [message] => funker jo ikke detta nå da :( får ikke spilt i det hele tatt :@
  [attachment] => Array(
    [description] => 
  )
  [impressions] => 
  [likes] => Array(
    [href] => http://www.facebook.com/browse/?type=likes&id=236459409726394
    [count] => 0
    [sample] => Array()
    [friends] => Array()
    [user_likes] => 
    [can_like] => 
  )
  [privacy] => Array(
    [value] => 
  )
  [permalink]开发者_StackOverflow中文版 => http://www.facebook.com/hacktheplanet.no/posts/236459409726394
  [comments] => Array(
    [can_remove] => 
    [can_post] => 
    [count] => 0
    [comment_list] => Array()
  )
)
[...]

Any suggestions or reasons why I don't get the impression data?


Have you tried this query for a post that is several days old?

Facebook Insights seems to usually be 24 to 48 hours behind and I believe that is the source of the impressions value.

To validate, I ran your FQL query for a post created today on a page that I have read_insights permissions for. The result for "impressions" was null (like in your example).

I then ran the same query for a post three days ago and the number of impressions was present.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜