Method: Koala::Facebook::TestUsers#initialize
- Defined in:
- lib/koala/test_users.rb
#initialize(options = {}) ⇒ TestUsers
Create a new TestUsers instance. If you don’t have your app’s access token, provide the app’s secret and Koala will make a request to Facebook for the appropriate token.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/koala/test_users.rb', line 33 def initialize( = {}) @app_id = [:app_id] @app_access_token = [:app_access_token] @secret = [:secret] unless @app_id && (@app_access_token || @secret) # make sure we have what we need raise ArgumentError, "Initialize must receive a hash with :app_id and either :app_access_token or :secret! (received #{options.inspect})" end # fetch the access token if we're provided a secret if @secret && !@app_access_token oauth = Koala::Facebook::OAuth.new(@app_id, @secret) @app_access_token = oauth.get_app_access_token end @api = API.new(@app_access_token) end |