javascript - Facebook API Error 100 - invalid link -


i using facebook api create send dialog in rails app. use format facebook recommends in javascript (as script in html).

my problem an:

 api error code 100, invalid parameter, link url not formatted 

on following:

 <script>      function detail(friend_id, user_name, restaurant_name, restaurant_id, articles){       // assume 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 '+ restaurant_name,            picture: 'http://fb-logo-75.png',           link: "<%= facebook::site_url%>restaurants/"+restaurant_id,           description: '<b>'+user_name + ' needs help.</b> add color review of <b>'+restaurant_name+'</b> , '+articles["object"]+' decide if should eat there.'           });     }      </script> 

please note that:

a) facebook::site_url changes depending on environment. may think localhost problem. when integrate value of website url (which valid website, unlike localhost) still error. yet link (to app on heroku ) functioning.

b) when post feed, whether localhost or in production, don't error. problem seems confined send dialog.

c) when put in url such http://www.cnn.com don't error. here how method called on 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 hack provides "his/him/he if user male, "her/her/hers if user female.

this how translates on client side:

the 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 script looks on client side:

function detail(friend_id, user_name, restaurant_name, restaurant_id, articles){   // assume logged in   fb.init({appid: 'xxxx', xfbml: true, cookie: true});    fb.ui({     to: friend_id,       method: 'send',       name: user_name +' needs more details '+ restaurant_name,        picture: 'http://fb-logo-75.png',       link: 'http://powerful-woodland-3700.herokuapp.com',       description: '<b>'+user_name + ' needs help.</b> add color review of <b>'+restaurant_name+'</b> , '+articles["object"]+' decide if should eat there.'       }); } 

note link functional link (albeit lot of bugs - exists , links actual website)

the image url of http://fb-logo-75.png not valid

it must absolute url (example: http://domain.com/path/to/image.png) , cannot located on facebook's cdn. change http://your_domain.com/path/to/fb-logo-75.png


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -