Facebook graph API : can post on “me/feed” but not

2019-08-09 15:14发布

问题:

I guess the answer to this one is straightforward but I cannot find it. Any help would be very much appreciated.

I. Use case

The application (back-end in python / django) should write on a facebook page.

II. Symptoms

  • When running the code below on "me/feed", the post is correctly inserted
  • When running the code below on "PAGE_ID/feed", there is an exception (see below in section IV.)
  • The scope of the authorisation is publish_stream, manage_pages
  • Also, the user_token is from a user in the test domain

III. Code

## Getting the user_access_token is dealt with before

h = Http()    

data = dict(message="Hello", access_token=user_access_token['access_token'])

resp, content = h.request("https://graph.facebook.com/PAGE_ID/feed", "POST", urlencode(data))

IV. Exception generated (using /PAGE_ID/feed)

resp : Response: {'status': '400', 'content-length': '119', 'expires': 'Sat, 01 Jan 2000 00:00:00 GMT', 'www-authenticate': 'OAuth "Facebook Platform" "invalid_request" "(#1) An unknown error occurred"', 'x-fb-rev': '976458', 'connection': 'keep-alive', 'pragma': 'no-cache', 'cache-control': 'no-store', 'date': 'Tue, 22 Oct 2013 21:45:20 GMT', 'access-control-allow-origin': '*', 'content-type': 'text/javascript; charset=UTF-8', 'x-fb-debug': 'HFItWh64ob+3hErv+rgYdFzHlRBVHP7Pg0Eg4hvqYlY='}

content str: {"error":{"message":"(#1) An unknown error occurred","type":"OAuthException","code":1,"error_data": {"kError":1455002}}}