Module: IGM
Constant Summary collapse
- INSTAGRAM_URL =
"https://api.instagram.com"
Instance Attribute Summary collapse
-
#client_id ⇒ Object
writeonly
Sets the attribute client_id.
-
#client_secret ⇒ Object
writeonly
Sets the attribute client_secret.
Instance Method Summary collapse
- #authorize_uri(params) ⇒ Object
- #configure {|_self| ... } ⇒ Object
- #get_access_token(params) ⇒ Object
- #get_user_info(token) ⇒ Object
Instance Attribute Details
#client_id=(value) ⇒ Object (writeonly)
Sets the attribute client_id
9 10 11 |
# File 'lib/igm.rb', line 9 def client_id=(value) @client_id = value end |
#client_secret=(value) ⇒ Object (writeonly)
Sets the attribute client_secret
9 10 11 |
# File 'lib/igm.rb', line 9 def client_secret=(value) @client_secret = value end |
Instance Method Details
#authorize_uri(params) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/igm.rb', line 15 def (params) params[:scope] = params[:scope].join("+") params[:client_id] = @client_id params[:response_type] = "code" query_string = params_to_query_string(params) "#{INSTAGRAM_URL}/oauth/authorize?#{query_string}" end |
#configure {|_self| ... } ⇒ Object
11 12 13 |
# File 'lib/igm.rb', line 11 def configure yield self end |
#get_access_token(params) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/igm.rb', line 25 def get_access_token(params) params[:client_id] = @client_id params[:client_secret] = @client_secret params[:grant_type] = "authorization_code" response = Nestful.post("#{INSTAGRAM_URL}/oauth/access_token", params) response = parse_response(response) response[:access_token] end |
#get_user_info(token) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/igm.rb', line 36 def get_user_info(token) response = Nestful.get("#{INSTAGRAM_URL}/v1/users/self?access_token=#{token}") response = parse_response(response) response[:data] end |