Created
June 20, 2012 13:38
-
-
Save samwgoldman/2959918 to your computer and use it in GitHub Desktop.
Easily create test users for facebook
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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