简体   繁体   中英

How to check whether a facebook event is “OPEN” and accessible using fb_graph

I set up a facebook application in rails using Nov Matake's fb_graph.

I'm trying to make a rake task that goes through a list of event ID's and then processes some of the event data. The ID's are both from open and private events, so I need to check whether the event is open.

I tried the following code to check whether the event can be accessed:

events.each do |event|
  if FbGraph::Event.fetch(event.identifier)
  # run code
  end
end

However when FbGraph::Event.fetch(event.identifier) returns false, the whole code stops running with the following error:

rake aborted! Graph API returned false, so probably it means your requested object is not found.

How can I check whether I can access an event or not?

For others coping with the same problem. I solved this by passing a facebook token with the request. Then I was able to get a valid response.

  testfetch = FbGraph::Event.fetch(event.identifier, :access_token => fb_token)
  if testfetch.privacy == "OPEN"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM