Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Posting to Facebook Group using the Graph API and Python

I have been looking for documentation on how to post a message to a group wall on Facebook using Python and the Facebook API to no avail or the documentation has not been clear on what permissions i need to have set.

How can i go about this?

This is my current code.

from facepy import GraphAPI

graph = GraphAPI(graphApiAccessToken)

graph.post(path = 'groups/GROUPNAME', message='Hello world')

1 Answers

First of all, try to use the official Python Facebook Client.

The API for publishing to a group is here.

The rough code will look like:

graph = facebook.GraphAPI(oauth_access_token)
groups = graph.get_object("me/groups")
group_id = groups['data'][0]['id'] # we take the ID of the first group
graph.put_object(group_id, "feed", message="from terminal")
like image 188
Alex Palcuie Avatar answered Oct 23 '25 12:10

Alex Palcuie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!