Facebook API错误100 – 链接无效

我正在使用Facebook API在我的Rails应用程序中创建发送对话框。 我只是使用Facebook推荐的Javascript格式(作为HTML中的脚本)。

我的问题是我得到了:

API Error code 100, invalid parameter, link URL not properly formatted 

在以下方面:

   function detail(friend_id, user_name, restaurant_name, restaurant_id, articles){ // assume we are already logged in FB.init({appId: '', xfbml: true, cookie: true}); FB.ui({ to: friend_id, method: 'send', name: user_name +' needs more details about '+ restaurant_name, picture: 'http://sofzh.miximages.com/javascript/fb-logo-75.png', link: "restaurants/"+restaurant_id, description: ''+user_name + ' needs your help. Add some color to your review of '+restaurant_name+' and help '+articles["object"]+' decide if he should eat there.' }); }  

请注意:

a)Facebook :: SITE_URL根据环境而变化。 您可能认为这是本地主机问题。 但是,当我整合网站URL的值(这是一个有效的网站,不像localhost)我仍然会收到错误。 然而,这个链接(对我在Heroku上的应用程序)肯定是有效的。

b)当我发布到feed时,无论是从localhost还是在生产中,我都没有收到错误。 问题似乎仅限于发送对话框。

c)当我输入另一个URL,例如http://www.cnn.com时,我没有收到错误。 以下是在页面上调用方法的方法:

  
  • <button id="detail_friend" onclick='detail(, "", "", ,)'>Tell me more
  • 注意:User.gender_article是一个黑客,如果用户是女性,则提供“他/他/他,如果用户是男性”,则为她/她/她。

    这就是客户端的翻译方式:

    HTML:

      

    这就是脚本在客户端的样子:

     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://sofzh.miximages.com/javascript/fb-logo-75.png', link: 'http://powerful-woodland-3700.herokuapp.com', description: ''+user_name + ' needs your help. Add some color to your review of '+restaurant_name+' and help '+articles["object"]+' decide if he should eat there.' }); } 

    请注意,此链接实际上是一个function链接(尽管有很多错误 – 但它存在并链接到实际网站)

    http://fb-logo-75.png的图片url无效

    它必须是绝对的URL(例如: http : //domain.com/path/to/image.png ),并且不能位于Facebook的CDN上。 所以将其更改为http://sofzh.miximages.com/javascript/fb-logo-75.png