Reputation:
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')
Upvotes: 4
Views: 11179
Reputation: 4974
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")
Upvotes: 12
Reputation: 409
If you prefer Django, you might also give this repo a try: https://github.com/tschellenbach/Django-facebook
Upvotes: 0
Reputation: 191
You are doing right till initializing GraphAPI instance after that you can post on group like this
graph.post('group_id/feed', message="your message here")
this worked for hope the same for you.
Upvotes: 0