2017-04-26 48 views
2

我试图获取Facebook页面信息和订阅源/帖子,特别是每篇文章的文本。 我已经在Facebook上为开发者注册了一个新的测试应用程序,并且我获得了客户令牌,秘密令牌和ID。我没有插入任何隐私链接或使用条款链接,因为它是个人测试。 在Graph API Explorer中,我得到应用程序访问令牌,并且正在使用它。使用Facebook-SDK 我可以通过下面的代码获取网页信息:使用Python中的Facebook API图获取页面订阅源

accessToken = "xxx" 
user = 'BillGates' 

graph = facebook.GraphAPI(accessToken, version='2.7') 

profile = graph.get_object(id=user, fields='id,name,about,link,location,hometown,website', limit=100) 

到目前为止,没有任何问题。现在,我希望获得的职位与此代码:

posts = graph.get_connections(profile['id'], connection_name='posts', fields='caption,created_time,description,from,link,message,object_id,parent_id,permalink_url,picture,privacy,place,properties,shares,source,status_type,story,to,type,with_tags', limit='100') 

或在此URL建立一个request.get()

url = "https://graph.facebook.com/v2.7/BillGates?fields=feed{caption,created_time,description,from,link,message,object_id,parent_id,permalink_url,picture,source,status_type,type}&limit=100&access_token=xxx" 

但我收到此错误:

facebook.GraphAPIError: (#15) Requires session when calling from a desktop app 

我的应用程序联系人电子邮件是本机或计算机应用程序(它将在Linux服务器上运行),是公开的,并且只有电子邮件,public_profile和user_friend作为批准的元素。其他元素不能被批准,因为我必须填写注释,但我无法填充它们。

我的想法是定期为我要分析的每个页面请求一个“常规”访问令牌或访问令牌。

任何帮助,将不胜感激。

+1

FYI解决:“本机或桌面应用程序”设置为需要嵌入客户端代码的应用程序秘密的应用程序。如果您的服务器上运行了应用程序,则不应将其设置为“是”。 – CBroe

+0

已解决将“本机或桌面应用程序”设置为否。谢谢:D –

回答

1

这个问题已经通过使用{} client_access_token作为

的access_token
url = "https://graph.facebook.com/v2.3/#{fb_id}/apprequests/?access_token=#{client_access_token}" 
相关问题