0

I'm able to retrieve the number of comments, shares and likes for a post of a Facebook page but I can't find a way to retrieve the number of likes (or "fans") a page has.

It is stated in the documentation that "To retrieve the number of likes for a page, use getUsers with the page IDs.".

My problem is that the getUsers() function return an error and getPage() contains no information regarding the number of fans, but only the number of likes per every single post.

> install.packages("Rfacebook")
> library(Rfacebook)
> token <- "XXXXXXXXXXXXXXXXXXXXXXXXXXX"
> getUsers("179106818789009", token=token)
Error in callAPI(query, token) : 
  (#100) Tried accessing nonexisting field (first_name) on node type (Page)
> 

How can I find this information ?

A workaround that uses the Facebook API with an url as proposed in another question also return an error :

https://graph.facebook.com/cocacola/?fields=fan_count&access_token=MY_TOKEN_HERE

{
   "error": {
      "message": "(#12) fan_count field requires version v2.6 or higher",
      "type": "OAuthException",
      "code": 12,
      "fbtrace_id": "F8JOCmpvFnX"
   }
}

Graph API how get facebook page members/likes

Florent
  • 1,791
  • 22
  • 40
  • so...why not use a higher api version then, as the error message suggests? – andyrandy Oct 27 '17 at 14:46
  • After my token expired I finally get it works with an OAuth Facebook app authentification, with : `https://graph.facebook.com/cocacola/?fields=fan_count&access_token=app_id|app_secret ` – Florent Oct 27 '17 at 15:13
  • Not sure what was wrong with the temporary token because the app is v2.10. – Florent Oct 27 '17 at 15:14

1 Answers1

0

As I said in the comments section I managed to get the fan_count by requesting the API with this url : https://graph.facebook.com/cocacola/?fields=fan_count&access‌​_token=app_id|app_se‌​cret

It needed a Facebook App that provides permanent access to the Facebook API.

Florent
  • 1,791
  • 22
  • 40