1

Through the following code I would like to get the impressions and other page insights in R:

library(Rfacebook)
library(RCurl)

fb_oauth <- fbOAuth(app_id="1967490963528780", app_secret="APP SECRET from 
https://developers.facebook.com/apps/myapp ",extended_permissions = TRUE)

insights <- getInsights(object_id="164028473612550", token=fb_oauth, 
metric='page_impressions')

I am owner of the page, however I get the following error:

Error in FUN(X[[i]], ...) : 
  No data available. Are you the owner of this page? See ?getInsights.

Does anyone know how to acces page insights through R?

nemja
  • 459
  • 4
  • 19
  • Is your token actually a page access token? – CBroe Nov 15 '17 at 09:45
  • No it is not. I follow the package documentation here: insights <- getInsights(object_id="20531316728", token=fb_oauth, metric='page_impressions') " – nemja Nov 15 '17 at 09:53
  • 1
    Since API v2.11, all page insight metrics require a page access token. – CBroe Nov 15 '17 at 09:55
  • I see, it might work! However, it says the acces token is expired. Can I create one that does not? – nemja Nov 15 '17 at 10:07
  • 1
    https://developers.facebook.com/docs/facebook-login/access-tokens/expiration-and-extension – CBroe Nov 15 '17 at 10:29
  • Nope, still returning the same error: No data available. Are you the owner of this page? See ?getInsights. – nemja Nov 15 '17 at 12:18
  • Suggest you test the requests (using same app id and token) in Graph API Explorer first, so that you can figure out whether it is a token/permission issue, or one with your code. – CBroe Nov 15 '17 at 12:33
  • That works!: GET/v2.11/164028473612550/insights/page_impressions – nemja Nov 15 '17 at 12:55
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/159060/discussion-between-nemja-and-cbroe). – nemja Nov 15 '17 at 13:05

0 Answers0