API错误代码:100 facebook OpenGraph [英] API Error code: 100 facebook OpenGraph

查看:257
本文介绍了API错误代码:100 facebook OpenGraph的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始制作一个新的Facebook应用程序,在heroku上托管,我还没有做任何修改,但是测试了一些功能,以习惯如何工作。直到我尝试发送消息按钮,出现一个对话框并显示以下错误日志:

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. 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);
              }
            }
          );
        });

我不认为 $有一个问题).attr('data-url'); 是以下作品(发贴到墙上的按钮):

The reason I don't think there is a problem with $(this).attr('data-url'); is that the following works (the post to wall button):

 $('#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() code>函数获取的值是:

The getUrl() function that gets the value is:

 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 的工作原理,而方法发送则没有。两种方法都在facebook sdk中定义

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. I think this problem is from facebook since method feed works, while method send does not. Both methods are defined in the facebook sdk

注意:我正在使用最新的php sdk

Note:I am using the latest php sdk

推荐答案

我仅使用发送对话框发生此问题。饲料出版工作很好,这是奇怪的。我在一个公共URL上使用动态查询字符串参数。

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.

我通过强制Facebook抓住之前的URL 来修复问题,我尝试通过FB UI发送对话框发送。使用FB API点击 graph.facebook.com ,其中发布在 id 参数和 scrape 参数设置为 true

I fixed the issue by forcing Facebook to scrape the URL before I attempt to send it via the FB UI Send Dialog. 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('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

I also answered with this solution to the same problem here.

这篇关于API错误代码:100 facebook OpenGraph的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆