我正在使用Facebook API在我的Rails应用程序中创建发送对话框。我只是使用Facebook推荐的Javascript格式(作为HTML中的脚本)。Facebook API错误100 - 无效链接
我的问题是,我得到一个:以下
API Error code 100, invalid parameter, link URL not properly formatted
:
<script>
function detail(friend_id, user_name, restaurant_name, restaurant_id, articles){
// assume we are already logged in
FB.init({appId: '<%= Facebook::APP_ID.to_s %>', xfbml: true, cookie: true});
FB.ui({
to: friend_id,
method: 'send',
name: user_name +' needs more details about '+ restaurant_name,
picture: 'http://fb-logo-75.png',
link: "<%= Facebook::SITE_URL%>restaurants/"+restaurant_id,
description: '<b>'+user_name + ' needs your help.</b> Add some color to your review of <b>'+restaurant_name+'</b> and help '+articles["object"]+' decide if he should eat there.'
});
}
</script>
请注意:
一)根据对环境的Facebook的:: SITE_URL变化。您可能认为这是本地主机问题。但是,当我整合网站URL(这是一个有效的网站,不像本地主机)的价值时,我仍然遇到错误。然而,这个链接(我Heroku 上的应用程序)肯定是正常运行。
b)当我发布feed时,无论是从localhost还是生产中,我都没有收到错误。这个问题似乎局限于发送对话框。
c)当我把另一个URL,如http://www.cnn.com我没有得到一个错误。 这里是方法是如何被调用的页面上:
<li class = "flat_list_item"><button id="detail_friend" onclick='detail(<%= review.user.fb_id.to_s %>, "<%= @current_user.first_name.to_s %>",
"<%= review.restaurant.name.to_s %>", <%= review.restaurant.id %>,<%= @current_user.gender_article.to_json %>)'>Tell me more</button></li>
注:User.gender_article是提供一个黑客“他/他/他,如果用户是男性,”她/她/她如果用户是女性。
这是如何转换的客户端:
的HTML:
<button id="detail_friend" onclick="detail(XXXX, "Laurent","Refuge", 227,{"subject":"he","possess":"his","object":"him"})">Tell me more</button>
这是剧本的样子在客户端:
function detail(friend_id, user_name, restaurant_name, restaurant_id, articles){
// assume we are already logged in
FB.init({appId: 'XXXX', xfbml: true, cookie: true});
FB.ui({
to: friend_id,
method: 'send',
name: user_name +' needs more details about '+ restaurant_name,
picture: 'http://fb-logo-75.png',
link: 'http://powerful-woodland-3700.herokuapp.com',
description: '<b>'+user_name + ' needs your help.</b> Add some color to your review of <b>'+restaurant_name+'</b> and help '+articles["object"]+' decide if he should eat there.'
});
}
注意这个链接实际上是一个功能链接(虽然有很多的错误 - 但它存在并链接到一个实际的网站)
客户端收到的_actual_ JS代码是什么? – CBroe 2013-04-05 09:32:11
@CBroe刚刚阐述了调用函数的代码。我可以带来更多的东西,请说。 – Laurent 2013-04-05 10:03:11
请显示客户端收到的代码,__after__您的ruby代码在服务器上执行。 – CBroe 2013-04-05 10:05:14