简体   繁体   English

API错误代码:100 facebook OpenGraph

[英]API Error code: 100 facebook OpenGraph

I have just started making a new Facebook app hosted on heroku and I haven't made any changes yet, but tested the functionality a little bit, to get used to how stuff works. 我刚刚开始在heroku上创建一个新的Facebook应用程序,我还没有做任何更改,但是稍微测试了一下这个功能,以便习惯这些东西是如何工作的。 All good until I try the "send message button", to which a dialog appears with the following error log: 一切顺利,直到我尝试“发送消息按钮”,出现一个对话框,出现以下错误日志:

An error occurred. Please try later

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

I've looked a bit in the related piece of code, and I find nothing wrong, but I am quite new so maybe any of you can help me a little bit to find out what's wrong: 我在相关的代码中看了一下,我发现没什么不对,但我很新,所以也许你们中的任何人都可以帮我一点找出错误:

    $('#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);
              }
            }
          );
        });

The reason I don't think there is a problem with $(this).attr('data-url'); 我不认为$(this).attr('data-url');存在问题的原因$(this).attr('data-url'); is that the following works (the post to wall button): 是以下工作(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);
          }
        }
      );
    });

  }

The getUrl() function that gets the value is: 获取值的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;

} }

Can anyone please help me? 谁能帮帮我吗? I've searched a bit on facebook developers forum and on stackoverflow, but the although the error code was the same, the error message was different. 我在facebook开发者论坛和stackoverflow上搜索了一下,但是虽然错误代码是相同的,但错误信息却不同。 I think this problem is from facebook since method feed works, while method send does not. 我认为这个问题来自facebook,因为方法feed工作,而方法send没有。 Both methods are defined in the facebook sdk 这两种方法都在facebook sdk中定义

Note:I am using the latest php sdk 注意:我使用的是最新的php sdk

I had this issue using the send dialog only. 我只使用发送对话框来解决这个问题。 The feed publishing worked fine which was odd. 饲料出版工作很好,很奇怪。 I was using dynamic querystring parameters on a common URL. 我在公共URL上使用动态查询字符串参数。

I fixed the issue by forcing Facebook to scrape the URL before I attempt to send it via the FB UI Send Dialog. 我通过强制Facebook 我尝试通过FB UI发送对话框发送URL 之前抓取URL来修复此问题。 Use the FB API to hit graph.facebook.com with the URL posted in the id parameter and a scrape parameter set to true . 使用FB API命中graph.facebook.com ,并在id参数中发布URL,并将scrape参数设置为true

Like so: 像这样:

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]'
    });
});

I also answered with this solution to the same problem here . 我也回答了这个解决方案同样的问题在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM