Question

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')
Was it helpful?

Solution

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

OTHER TIPS

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.

If you prefer Django, you might also give this repo a try: https://github.com/tschellenbach/Django-facebook

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top