简体   繁体   English

Facebook API错误100-无效链接

[英]Facebook API Error 100 - invalid link

I am using the Facebook API to create a Send Dialog in my Rails App. 我正在使用Facebook API在Rails应用程序中创建“发送”对话框。 I just use the format that Facebook recommends in a Javascript (as a script in HTML). 我只是使用Facebook在Javascript中推荐的格式(作为HTML中的脚本)。

My problem is that I get an: 我的问题是我得到了:

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

on the following: 在以下内容上:

 <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>

Please note that: 请注意:

a) The Facebook::SITE_URL changes depending on the environment. a)Facebook :: SITE_URL随环境而变化。 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. 但是,当我整合网站URL的值(这是一个有效的网站,与localhost不同)时,仍然会出现错误。 Yet that link (to my app on Heroku ) is definitely functioning. 但是,该链接(到我在Heroku上的应用程序)肯定有效。

b) When I post to feed, whether from localhost or in production, I don't get an error. b)无论是从本地主机还是在生产环境中发布供稿时,都不会出现错误。 The problem seems confined to the Send Dialog. 该问题似乎仅限于“发送”对话框。

c) when I put in another URL such as http://www.cnn.com I don't get an error. c)当我输入另一个URL(例如http://www.cnn.com )时,没有收到错误消息。 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>

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. 注意:User.gender_article是一种黑客程序,如果用户是男性,则提供“他/他/他”;如果用户是女性,则提供“他/她/她”。

This is how this translates on the client side: 这就是在客户端翻译的方式:

The HTML: 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) 请注意,此链接实际上是功能性链接(尽管存在许多错误-但它存在并且链接到实际网站)

The image URL of http://fb-logo-75.png is not valid http://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. 它必须是绝对网址(例如: http : //domain.com/path/to/image.png ),并且不能位于Facebook的CDN上。 So change that to http://your_domain.com/path/to/fb-logo-75.png 因此,将其更改为http://your_domain.com/path/to/fb-logo-75.png

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Facebook上的错误,API错误代码:100,API错误描述:无效参数,错误消息:链接URL格式不正确 - Error on Facebook, API Error code: 100, API error description: invalid parameter, Error message: link URL is not properly formatted Facebook API返回错误代码100 - Facebook api return error code 100 API错误代码:100 facebook OpenGraph - API Error code: 100 facebook OpenGraph 反应| Facebook JS API:尝试将多个图像上传到我的页面Feed时出现错误代码100 - React | Facebook JS API : Error code 100 when trying to upload multiple images to my page feed Facebook share_open_graph错误:“无效的操作链接URL:帖子的操作链接必须是有效的URL。” - Facebook share_open_graph error: “Invalid Action Link URL: The post's action links must be valid URLs.” Facebook Graph API - 发布应用程序链接 - Facebook Graph API - Post Link to App 错误错误:未捕获(承诺):无效链接:SosPopPage - ERROR Error: Uncaught (in promise): invalid link: SosPopPage 将Facebook链接到Firebase Anonymous Auth,无需调用Facebook API - Link Facebook to Firebase Anonymous Auth without calling Facebook API 指定的版本无效,facebook 分享插件错误 - Invalid version specified, facebook share plugin error Facebook Payments API-错误,无代码 - Facebook payments API - Error with no code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM