【发布时间】:2020-02-26 18:11:24
【问题描述】:
我想将 SalesForce 与 Facebook Messenger 集成。为此,我检索了访问令牌、应用程序 ID、应用程序密码。当我在开发者控制台中点击 HTTP 请求发送消息时,出现错误。
在给定的代码中,它不接受消息作为参数抛出错误,而是在没有消息的情况下工作。 参考: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());
错误信息:
16:55:58:127 USER_DEBUG [16]|DEBUG|{"error":{"message":"不支持 发布请求。 ID 为“我”的对象不存在,由于无法加载 缺少权限,或不支持此操作。请 阅读 Graph API 文档,网址为 https://developers.facebook.com/docs/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"AcqDT5M6mGXSOCr4mOd3kDf"}} 实际响应:成功 = true
【问题讨论】:
-
这意味着需要其他权限。见这里HERE
-
错误消息似乎与您显示的代码不匹配。您在代码中使用了特定 ID,而错误消息显示您使用的是
me快捷方式。
标签: facebook salesforce integration apex