graph api get public events with rails/koala works only for some sites

568 views Asked by At

This is my code

Koala.config.api_version = 'v2.3'
@oauth = Koala::Facebook::OAuth.new 'app_id', 'app_secret'
@graph = Koala::Facebook::API.new @oauth.get_app_access_token

@events = @graph.get_object('141991029192409/events')

which works fine. If I try to fetch the events from another site like

@events = @graph.get_object('161335993890217/events')

I get this error

GraphMethodException, code: 100, message: Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api [HTTP 400]

1

There are 1 answers

2
CBroe On BEST ANSWER

That page is likely restricted in some way (alcohol related content, age, location) – and that means you need to use a user access token instead of the app access token. (Or a page access token, if you have admin control over that page.)

With a user access token, Facebook uses the information about that user to determine whether or not they are allowed to see the page. An app access token could be used by “anyone”, and therefor can not be used to access such restricted pages.