我正在编写一个将访问用户的Facebook照片的python桌面应用程序。该应用程序目前支持flickr,它使用了类似的oauth身份验证过程,但我正在努力弄清楚如何验证Facebook的应用程序。为Flickr,基本步骤是:在python桌面应用程序中获取facebook用户/应用程序令牌
- 应用程序打开认证页面上的浏览器
- 用户提供了应用程序的访问权限
- 应用接收的令牌作为HTTP响应,然后可以使用该帐户与flickr的api
我希望有类似的脸谱,但我一直没能弄明白。
python有各种各样的facebook API库,比如Pyfb,它提供了一种访问图形数据的简单方法,但它们都没有提供一种明显的方式来执行上面的认证步骤并检索可以是用过的。下面是从Pyfb,其推测用户令牌用户,这是一个桌面应用程序完全荒谬的手动输入的例子...
from pyfb import Pyfb
#Your APP ID. You Need to register the application on facebook
#http://developers.facebook.com/
FACEBOOK_APP_ID = 'YOUR_APP_ID'
pyfb = Pyfb(FACEBOOK_APP_ID)
#Opens a new browser tab instance and authenticates with the facebook API
#It redirects to an url like http://www.facebook.com/connect/login_success.html#access_token=[access_token]&expires_in=0
pyfb.authenticate()
#Copy the [access_token] and enter it below
token = raw_input("Enter the access_token\n")
#Sets the authentication token
pyfb.set_access_token(token)
#Gets info about myself
me = pyfb.get_myself()