简体   繁体   English

如何在图形API中获取当前的access_token?

[英]How to get current access_token in graph api?

i working on graph api in python in appengine , and i want to get access_token to to be able to create a new album 我在appengine中的python中使用graph api ,并且我希望获得access_token才能创建新专辑

  base_url = "https://graph.facebook.com/me/albums"
    encoded_album_name= urllib.quote("refacingme.appspot.com")
    name="&name="+encoded_album_name
    type="&type=post"
    access_token="&access_token="+str(fb.uid)    
    opener = urllib2.build_opener()
    opener.addheaders = [('Accept-Language', 'en-US,en;q=0.8')]
    url = "%s%s%s%s" % (base_url,access_token,type,name)

The best way I've found to get the access token is to use the get_user_from_cookie method of the facebook python sdk. 我发现获取访问令牌的最好方法是使用facebook python sdk的get_user_from_cookie方法。 There's an example usage in the comments of the file: 该文件的注释中有一个用法示例:

https://github.com/facebook/python-sdk/blob/master/src/facebook.py https://github.com/facebook/python-sdk/blob/master/src/facebook.py

This requires that the cookie gets set from the facebook javascript sdk in the browser. 这要求从浏览器中的facebook javascript sdk设置cookie。 You may also need to request permissions (also done through the javascript sdk). 您可能还需要请求权限(也可以通过javascript sdk完成)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM