Search code examples
facebook-graph-api

facebook graph api pages post message


I wanted to make a facebook API request that will post a message to page that I am admin of. Here i found out how can i do that but after trying it out in facebook graph api explorer with this scheme:

 graph.facebook.com/page-id/feed
  ?message=Hello&access_token=your-access-token" 

assuming I have a developer account linked to my page and publish_pages and manage_pages permissions are enabled and page-id and acces-token are replaced with my real ones. The problem is that I get a response of latest post on that website, the same as if I would write just graph.facebook.com/page-id/feed and there is no new post on my page. I dont know if the recent facebook API update removed or modified that or if its just not possible.


Solution

  • trying it out in facebook graph api explorer with this scheme

    graph.facebook.com/page-id/feed?message=Hello&access_token=your-access-token
    

    You are making a GET request here - and GET is for reading data, not creating it.

    Creating data requires a POST request. So you can either switch the request method from GET to POST via the dropdown there, and then click + Add parameter to add your parameters and values;

    or you can add &method=post to the end of your GET request query string here - that is a way the API offers to explicitly overwrite the request method in environments, where you can only make GET requests.