[英]API Error code: 100 facebook OpenGraph
我刚刚开始在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');
存在问题的原因$(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
我只使用发送对话框来解决这个问题。 饲料出版工作很好,很奇怪。 我在公共URL上使用动态查询字符串参数。
我通过强制Facebook 在我尝试通过FB UI发送对话框发送URL 之前抓取URL来修复此问题。 使用FB API命中graph.facebook.com
,并在id
参数中发布URL,并将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]'
});
});
我也回答了这个解决方案同样的问题在这里 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.