0

I want to integrate SalesForce with Facebook Messenger. For this I've retrieved access token, app id , app secret. When I hit a HTTP request in developer console to send a message then there is an error.

In the given code it is not accepting messages as parameter throwing error but working without messages. ref: https://developers.facebook.com/docs/messenger-platform/send-messages/?translation#sending_text

Httprequest req = new httpRequest();
req.setEndPoint('https://graph.facebook.com/v5.0/1798927698340/messages?access_token={PUT-ACCESS-TOKEN-HERE}');
String body = '{'+
                '"recipient": {'+
                '"id": "100042977199143"'+
                '},'+
                '"message": {'+
                '"text": "hello, world!"' +
                '}' +
                '}';
req.setMethod('POST');
req.setHeader('Content-Type','application/json');
Http h = new Http();
HttpResponse res = h.send(req);
system.debug(res.getBody());

error message :

16:55:58:127 USER_DEBUG [16]|DEBUG|{"error":{"message":"Unsupported post request. Object with ID 'me' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"AcqDT5M6mGXSOCr4mOd3kDf"}} actual response : success = true

tomRedox
  • 28,092
  • 24
  • 117
  • 154
  • This means that there are other permissions required. See here [HERE](https://stackoverflow.com/questions/6843796/graph-api-returns-false-or-unsupported-get-request-accessing-public-facebook/6847088#6847088) – badri Oct 31 '19 at 18:55
  • The error message does not seem to match the code you have shown. You are using a specific ID in your code, whereas the error message says you were using the `me` shortcut. – 04FS Nov 01 '19 at 08:16

1 Answers1

0

This problem arises sometimes when we use invalid access token or user access token instead of page access token.