Facebook API错误100 - 无效链接 [英] Facebook API Error 100 - invalid link

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

问题描述

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

I am using the Facebook API to create a Send Dialog in my Rails App. I just use the format that Facebook recommends in a Javascript (as a script in HTML).

我的问题是我得到一个:

My problem is that I get an:

 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>

请注意:

a) Facebook :: SITE_URL根据环境而变化。你可能认为这是一个localhost问题。然而,当我整合网站URL(这是一个有效的网站,不同于localhost)的值时,我仍然收到错误。然而,这个链接(对我的Heroku
的应用程序)肯定是有效的。

a) The Facebook::SITE_URL changes depending on the environment. You may think this is a localhost problem. However when I integrate the value of the website URL (which is a valid website, unlike localhost) I still get an error. Yet that link (to my app on Heroku ) is definitely functioning.

b)当我发布feed,无论是从本地主机还是在生产中,我不会有错误。问题似乎局限于发送对话框。

b) When I post to feed, whether from localhost or in production, I don't get an error. The problem seems confined to the Send Dialog.

c)当我放入另一个URL,如 http://www.cnn.com 我没有收到错误。
这是在页面上如何调用方法:

c) when I put in another URL such as http://www.cnn.com I don't get an error. Here is how the method is called on the page:

    <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是一个黑客,提供他/他/他,如果用户是男性,如果用户是女性,她/她/她的。

NOTE: User.gender_article is a hack that provides "his/him/he if the user is male, "her/her/hers if the user is female.

这是客户端如何翻译:

HTML:

<button id="detail_friend" onclick="detail(XXXX, &quot;Laurent&quot;,&quot;Refuge&quot;, 227,{&quot;subject&quot;:&quot;he&quot;,&quot;possess&quot;:&quot;his&quot;,&quot;object&quot;:&quot;him&quot;})">Tell me more</button>

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

And this is what the script looks like on the client side:

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

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

Note that this link actually is a functional link (albeit with a lot of bugs - but it exists and links to an actual website)

推荐答案

http://fb-logo-75.png 无效

它必须是绝对网址(例如: http://domain.com/path/to/image.png),不能位于Facebook的CDN上。因此,请将其更改为 http://your_domain.com/path/to/fb-logo -75.png

It must be an absolute url (example: http://domain.com/path/to/image.png) and cannot be located on Facebook's CDN. So change that to http://your_domain.com/path/to/fb-logo-75.png

这篇关于Facebook API错误100 - 无效链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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