-1

Recently , exploring Facebook Messenger's Send Api and I got confused in accessing SendApi through Python requests.

1 Answers1

0

So, the format which works for me is -

headers = {
    'Content-Type': 'application/json',
}
request_body = json.dumps({
        "recipient": {
        "id": sender_psid
        },
        "message": message
    })
params = {'access_token':PAGE_ACCESS_TOKEN}
url = "https://graph.facebook.com/v2.6/me/messages"
r = requests.post(url = url, data = request_body, headers = headers, params=params)

or you can add access_token in request_body too. Declaring headers is important here