发送对话框返回成功或失败

时间:2013-11-01 15:20:37

标签: facebook facebook-graph-api facebook-javascript-sdk

我想知道如何通过发送facebook对话框发送私信后如何获得回复。

示例:

      FB.ui({
          app_id:"XXXXXXXXXXXXXXXXXXXXXXXXX",
          method: 'send',
          name: "Test send message",
          link: 'www.mywebsite.gi',
          to: ID_USER_FB,
          description:'This is a test '

      });
      // here i would a response
      if (response == TRUE) {
         // do this
      } else {
        // do that
      }

1 个答案:

答案 0 :(得分:1)

FB.ui方法有两个参数:数据对象和回调函数,如下所示:FB.ui

回调函数将是这样的:

  function(response) {
    if (response && response.post_id) {
      alert('Post was published.');
    } else {
      alert('Post was not published.');
   }

需要注意的重要一点是FB.ui方法是异步的,这就是它需要回调方法的原因。