Sha256: 88535cd655e73b6d18944c636d804e6a38d83a576e56a347410d69eb60e1656b

Contents?: true

Size: 814 Bytes

Versions: 2

Compression:

Stored size: 814 Bytes

Contents

class FacebookEvents

  require 'mini_fb'
  require 'facebook_events/event'
  require "facebook_events/version"

  # Get events for a Facebook page or user by id.
  # Requires environment variables for Facebook APP ID and APP Secret:
  #   FacebookEvents::FACEBOOK_APP_ID = ...
  #   FacebookEvents::FACEBOOK_SECRET = ...

  attr_reader :facebook_id, :auth_token, :list

  def initialize(facebook_id)
    @facebook_id = facebook_id
    @auth_token  = get_auth_token
    @list        = get_events
  end

  private

  def get_auth_token
    MiniFB.authenticate_as_app(FACEBOOK_APP_ID, FACEBOOK_SECRET)['access_token']
  end

  def get_events
    list = MiniFB.get(@auth_token, @facebook_id, :type => 'events').data
    list.map do |e|
      FacebookEvents::Event.new(MiniFB.get(@auth_token, e.id))
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
facebook_events-0.0.2 lib/facebook_events.rb
facebook_events-0.0.1 lib/facebook_events.rb