I'm using Facebook oauth and koala gems to create an app that helps with event management on the fly. I have successfully listed simple information about myself, events I've been invited to, and people I'm friends with.
I understand that people and event objects have sibling relationships so you cannot find information of one in another aside for what events you've been invited to. So how do You list events that you're a host of?
Here's how I did it. In User.rb after self.from_omniauth method: :
def facebook
@facebook ||= Koala::Facebook::API.new(oauth_token)
block_given? ? yield(@facebook) : @facebook
rescue Koala::Facebook::APIError => e
logger.info e.to_s
nil
end
def api_call
query = "Me?fields=picture.type(large),location,events.fields(name,location,end_time,privacy,updated_time,description,rsvp_status,venue,start_time,id,ticket_uri,picture.type(large),cover,owner,admins.fields(picture.type(large),name,location),attending.fields(picture.type(large),name,rsvp_status,first_name,last_name,email,location),maybe.fields(rsvp_status,picture.type(large),name,first_name,last_name,email,age_range,location)),friends.fields(cover,id,gender,location,username,email,first_name,last_name,picture.type(large))"
end
def generate_user_events
fb_call = facebook { |fb| fb.graph_call(api_call)}
unless fb_call["events"].nil?
events = fb_call["events"]["data"]
events.each do |event|
#All information from each event.
end #/ each do |event|
end #/ check to see if user has events
end
end