我开始学习facepy,当我尝试从facepy发布时,我收到错误。但我可以得到帖子的详细信息。我的代码:
>>> from facepy import GraphAPI
>>>g = GraphAPI('my_token')
>>> g.get(506482556089521)['from']
{u'name': u'Aswin Murugesh', u'id': u'100001833444044'}
>>> g.post(
... path = 'me/posts',
... message = 'Hello'
... )
Traceback (most recent call last):
File "<stdin>", line 3, in <module>
File "/usr/local/lib/python2.7/dist-packages/facepy/graph_api.py", line 65, in post
retry = retry
File "/usr/local/lib/python2.7/dist-packages/facepy/graph_api.py", line 237, in _query
return load(method, url, data)[0]
File "/usr/local/lib/python2.7/dist-packages/facepy/graph_api.py", line 201, in load
result = self._parse(response.content)
File "/usr/local/lib/python2.7/dist-packages/facepy/graph_api.py", line 279, in _parse
error.get('code', None)
facepy.exceptions.FacebookError
为什么我会收到此错误?
答案 0 :(得分:2)
因为你没有发布来自facebook的回复消息
我看到你错过的是
>>> g.post(
... path = 'me/posts',
... message = 'Hello'
... )
您使用的路径不正确。如果您调试错误,您将获得
{
"error": {
"message": "Unsupported post request.",
"type": "GraphMethodException",
"code": 100
}
}
将讯息发布到墙上的正确路径是me/feed
您可以在此处https://developers.facebook.com/tools/explorer/?method=POST&path=me%2Ffeed
>>> g.post(
... path = 'me/feed',
... message = 'Hello'
... )
如果仍然出现错误,则您的问题可能没有publish_stream
权限
有关详细信息:https://developers.facebook.com/docs/reference/api/publishing/