Skip to content

Instantly share code, notes, and snippets.

@caguiclajmg
Created January 6, 2020 15:28
Show Gist options
  • Save caguiclajmg/c9d1c0d464f6a2d07b5652eb9904fb41 to your computer and use it in GitHub Desktop.
Save caguiclajmg/c9d1c0d464f6a2d07b5652eb9904fb41 to your computer and use it in GitHub Desktop.
import facebook
import requests
accessToken = "page_access_token_here"
graph = facebook.GraphAPI(access_token=accessToken, version="3.1")
parent = graph.put_object(
parent_object="page_id_here",
connection_name="feed",
message="Bruh Test")
parentId = parent["id"]
# write a comment with an attached image
r = requests.post("https://graph.facebook.com/v5.0/" + parentId + "/comments", data = {
"access_token": accessToken,
"message": "bruh"
}, files = {
"source": open("/path/to/image.jpg", "rb")
})
graph.delete_object(parentId)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment