通过FB API回复页面时,消息为空

时间:2016-03-07 13:08:33

标签: javascript facebook api facebook-graph-api

我试图通过Facebook API回复页面。

我可以通过Graph API回复该页面。将应用程序设置在我的应用程序的右上方。获取我的页面令牌,输入"/{conversation-id}/messages",切换到POST,单击添加字段,然后添加键值对 - "消息" "这是我的消息",点击提交即可生效,消息会显示在聊天中。

当我尝试通过我的应用程序回复时,它似乎已经通过,我没有收到任何错误,并且一旦提交了该消息的uuid就会返回给我。它没有出现在聊天中,我得到了我的页面图标,比如发送空消息,或者我收到消息

  

"附件不可用此附件可能已被删除或   分享它的人可能不会......"

如果我使用消息的uuid并检查Graph API,我可以看到消息确实已创建,但是"消息"字段是空的,就像被剥离一样。

我在我的应用中使用的代码:

  postMessage: function($scope, pageToken, thread, message){
    FB.api("/"+ thread +"/messages", "POST", {"message": "message"},
      function (response) {
        if (response && !response.error) {
           console.log("Success")
        }else{
           console.log("failed")
        }
      }, {access_token: pageToken}
    );
  }

不确定为什么会发生这种情况,我无法在网上找到任何相关信息。

非常感谢任何帮助。

谢谢,

百里

1 个答案:

答案 0 :(得分:0)

我想通了,这对我来说是一个简单的疏忽,我需要在POST之后传递access_token,而不是在函数的底部。

 postMessage: function($scope, pageToken, thread, message){
    FB.api("/"+ thread +"/messages", "POST", {"access_token": pageToken, "message": "message"},
      function (response) {
        if (response && !response.error) {
           console.log("Success")
        }else{
           console.log("failed")
        }
      }
    );
  }