Skip to content

Instantly share code, notes, and snippets.

@jaigouk
Created November 16, 2011 15:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaigouk/1370390 to your computer and use it in GitHub Desktop.
Save jaigouk/1370390 to your computer and use it in GitHub Desktop.
How to use apigee with koala
if ENV['APIGEE_FACEBOOK_API_ENDPOINT']
Koala::Facebook.rest_server = ENV['APIGEE_FACEBOOK_API_ENDPOINT']
else
# Get this value from Heroku.
# Once you have enabled the addon, boot up the 'heroku console' and run the following:
# puts ENV['APIGEE_FACEBOOK_API_ENDPOINT']
Koala::Facebook.rest_server = "facebook-api-appXXXXXX.apigee.com"
end
module Facebook
APP_ID = Settings.facebook.app_id
SECRET = Settings.facebook.app_secret
end
Koala::Facebook::OAuth.class_eval do
def initialize_with_default_settings(*args)
case args.size
when 0, 1
raise "application id and/or secret are not specified in the config" unless Facebook::APP_ID && Facebook::SECRET
initialize_without_default_settings(Facebook::APP_ID.to_s, Facebook::SECRET.to_s, args.first)
when 2, 3
initialize_without_default_settings(*args)
end
end
alias_method_chain :initialize, :default_settings
end
# facebook library for Ruby, supporting the Graph API (including the batch requests and photo uploads), the REST API, realtime updates, test users, and OAuth validation
gem 'koala', :git => 'git@github.com:jaigouk/koala.git'
require 'koala'
namespace :koala do
desc "testing koala with apigee"
task :dance => :environment do
# step1. change graph server to apigee
Koala::Facebook.rest_server= "facebook-api-appXXXXXX.apigee.com"
puts "_______________"
puts Koala::Facebook.rest_server
# step2. oauth
app_id = "my_id"
app_secret = "secret"
callback_url = "http://callback.com"
oauth = Koala::Facebook::OAuth.new(app_id, app_secret, callback_url)
oauth_access_token = oauth.get_app_access_token
graph = Koala::Facebook::API.new(oauth_access_token)
puts graph.search("koala")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment