Skip to content

Commit

Permalink
updated bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismatthieu committed Sep 29, 2010
1 parent 14ff526 commit 3980d18
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ GEM
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.5)
rack-test (0.5.6)
rack (>= 1.0)
rails (3.0.0)
actionmailer (= 3.0.0)
Expand Down
20 changes: 14 additions & 6 deletions app/controllers/authorize_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,28 @@ def new
end

def oauth_redirect
code = params[:code]
code = params[:code]

resp = RestClient.get "https://graph.facebook.com/oauth/access_token", {:params => {:client_id => "104425026288823", :redirect_uri => 'http://telephone.heroku.com/oauth_redirect', :client_secret => 'a4807180f4586dc5df989d4d03e242b1', :code => code}}

if resp.body
begin
resp = RestClient.get "https://graph.facebook.com/oauth/access_token", {:params => {:client_id => "104425026288823", :redirect_uri => 'http://telephone.heroku.com/oauth_redirect', :client_secret => 'a4807180f4586dc5df989d4d03e242b1', :code => code}}
rescue => e
e.response
end

if !e.nil? and resp.body
mytoken = resp.body.gsub("access_token=", "")

accesstoken = mytoken.split("&")[0]
expires = mytoken.split("&")[1].gsub('expires=', '')

#Now fetch and update user data
userresp = RestClient.get "https://graph.facebook.com/me", {:params => {:access_token => accesstoken, :expires => expires}} #rescue nil
begin
userresp = RestClient.get "https://graph.facebook.com/me", {:params => {:access_token => accesstoken, :expires => expires}}
rescue => e
e.response
end

if !userresp.nil? and userresp.body
if !e.nil? and userresp.body
data = userresp.body
result = JSON.parse(data)

Expand Down

0 comments on commit 3980d18

Please sign in to comment.