Skip to content

Instantly share code, notes, and snippets.

@bguest
Created October 24, 2012 07:15
Show Gist options
  • Save bguest/3944515 to your computer and use it in GitHub Desktop.
Save bguest/3944515 to your computer and use it in GitHub Desktop.
Ruby Koala gem script to invite all members of multiple groups to an event
require 'koala'
require 'date'
require 'enumerator'
# create_event permision is needed
access_token ='<access_token>'
groups = ["<group1id>","<group2id>"]
graph = Koala::Facebook::API.new(access_token)
invites = {}
groups.each do |g|
members = graph.get_connections(g,'members')
members.each do |m|
invites[m['id']] = m['name']
end
end
# Create Event
params = {
# :picture => picture,
:name => 'Event name',
:description => 'Event description',
:start_time => Date.new(2012,12,31).to_time.to_s,
:end_time => Date.new(2013,1,01).to_time.to_s
}
event = graph.put_object('me', 'events', params )
invites.keys.enum_for(:each_slice,4).each do |group|
graph.put_object(event['id'],'invited',:users =>group.join(','))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment