Вопрос

I am startingto learn facepy and when I tried to post from facepy, I get an error. But I can get post details. My code:

>>> 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

Why do I get this error?

Это было полезно?

Решение

Because you not post message that response from facebook

What I see that you miss is

>>> g.post(
...     path = 'me/posts',
...     message = 'Hello'
... )

You use incorrect path. If you debug the error you will got

{
  "error": {
    "message": "Unsupported post request.", 
    "type": "GraphMethodException", 
    "code": 100
  }
}

The correct path to post a message to your wall is me/feed You can test it here https://developers.facebook.com/tools/explorer/?method=POST&path=me%2Ffeed

>>> g.post(
...     path = 'me/feed',
...     message = 'Hello'
... )

If it still get the error, your problem might be not have publish_stream permission

For more information : https://developers.facebook.com/docs/reference/api/publishing/

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top