I want to get a list of all the Facebook users who have liked our Facebook page using the Koala gem for Ruby on Rails.
Ideally returned as a JSON hash with the user objects so can get access to their feeds, and using just the page access token as we currently do not offer Facebook login.
The docs say acting as a page is much the same as acting as a user and the same commands should work. Which means this should work -
@page_graph.get_connections("me", "friends")
But this returns -
Koala::Facebook::ClientError: type: OAuthException, code: 100, message: (#100) Tried accessing nonexisting field (friends) on node type (Page), x-fb-trace-id: EzD1J26UONf [HTTP 400]
The only other Stack post I can find on this is here -
Rails, Facebook API, Koala gem — get all profiles of users who 'Like' a page
But this is very old and does not work.
Thanks.
https://developers.facebook.com/docs/graph-api/reference/v3.3/object/likes
A User or Page can only query their own likes.
In other words, you can only get Pages that are liked by the Page in question - or Pages that are liked by the User, if authorized with the user_likes
permission and with a User Token.
There is no way to get Page Fans, and accessing the posts of a User is only possible by authorizing that User with the user_posts
permission.
Btw, /me/friends
is for getting the friends of a User, and it would only return friends who authorized the App too.