Skip to content

Instantly share code, notes, and snippets.

@samwgoldman
Created June 20, 2012 13:38
Show Gist options
  • Save samwgoldman/2959918 to your computer and use it in GitHub Desktop.
Save samwgoldman/2959918 to your computer and use it in GitHub Desktop.
Easily create test users for facebook
require "httparty"
class FacebookTestUser
include HTTParty
base_uri "graph.facebook.com:443"
attr_reader :email, :password
def initialize(options)
@email = options["email"]
@password = options["password"]
end
def self.create(name, access_token = get_access_token)
response = get "/#{app_id}/accounts/test-users", :query => { :installed => false, :name => name, :method => "post", :access_token => access_token }
new(response.parsed_response)
end
def self.get_access_token
response = get "/oauth/access_token", :query => { :client_id => app_id, :client_secret => app_secret, :grant_type => "client_credentials" }
CGI.parse(response.body)["access_token"][0]
end
def self.app_id
config[:facebook][:app_id]
end
def self.app_secret
config[:facebook][:app_secret]
end
private
def self.config
...snip...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment