API错误代码:100 facebook OpenGraph

时间:2013-03-08 20:35:52

标签: php javascript facebook facebook-graph-api heroku

我刚刚开始在heroku上创建一个新的Facebook应用程序,我还没有做任何更改,但是稍微测试了一下这个功能,以便习惯它的工作方式。一切顺利,直到我尝试“发送消息按钮”,出现一个对话框,出现以下错误日志:

An error occurred. Please try later

API Error Code: 100
API Error Description: Invalid parameter
Error Message: 'link' is invalid.

我在相关的代码中看了一下,我发现没有错,但我很新,所以也许你们中的任何人都可以帮我一点找出错误:

    $('#sendToFriends').click(function() {
          FB.ui(
            {
              method : 'send',
              link   : $(this).attr('data-url')
            },
            function (response) {
              // If response is null the user canceled the dialog
              if (response != null) {
                logResponse(response);
              }
            }
          );
        });

我认为$(this).attr('data-url');没有问题的原因是以下工作(post to wall按钮):

 $('#postToWall').click(function() {
      FB.ui(
        {
          method : 'feed',
          link   : $(this).attr('data-url')
        },
        function (response) {
          // If response is null the user canceled the dialog
          if (response != null) {
            logResponse(response);
          }
        }
      );
    });

  }

获取值的getUrl()函数是:

 public static function getUrl($path = '/') {
if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1)
  || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'
) {
  $protocol = 'https://';
}
else {
  $protocol = 'http://';
}

return $protocol . $_SERVER['HTTP_HOST'] . $path;

}

任何人都可以帮助我吗?我在facebook开发者论坛和stackoverflow上搜索了一下,但是虽然错误代码是相同的,但错误信息却不同。我认为这个问题来自facebook,因为方法feed有效,而方法send没有。这两种方法都在facebook sdk中定义

注意:我使用的是最新的php sdk

1 个答案:

答案 0 :(得分:2)

我只使用发送对话框来解决此问题。饲料出版工作很好,很奇怪。我在公共URL上使用动态查询字符串参数。

我通过强迫Facebook在之前抓取网址来解决问题我试图通过FB UI发送对话框发送它。使用FB API点击graph.facebook.com,其中id参数中发布的网址和scrape参数设置为true

像这样:

FB.api('https://graph.facebook.com/', 'post', {
    id: '[URL]',
    scrape: true
}, function(response) {
    FB.ui({
        method: 'send',
        name: '[name]',
        picture: '[Picture URL]',
        link: '[URL]',
        description: '[description]'
    });
});

我也回答了这个问题的解决方案here