2011-05-04 30 views
0

在此閱讀oauth tutorial如何爲Facebook API實現同樣的功能?

下面的代碼顯示瞭如何在Twitter的API上獲得訪問令牌。我想爲使用OAuth的Facebook API做同樣的事情。

#oauth = OAuth::Consumer.new(APP_CONFIG['twitter_consumer_key'], APP_CONFIG['twitter_consumer_secret'], :site => 'http://api.twitter.com', :request_endpoint => 'http://api.twitter.com', :sign_in => true) 

# Get the request tokens from the API 
rt = oauth.get_request_token 
rtoken = rt.token # request token 
rsecret = rt.secret # request token secret 

# Go to url and click ""Allow access」 when prompted 
# http://api.twitter.com/oauth/authorize?oauth_token=your_request_token_from_above 

# Get the access tokens from the API 
at = rt.get_access_token 
oauth_token = at.token 
oauth_token_secret = at.secret 

任何人都知道這是如何實現的?

回答

相關問題