Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook FB.ui send dialog intermittently returns invalid link error

This has been working fine for over a week.

FB.ui({
  method: 'send',
  to: connectionid,
  name: subject,
  picture: staticurl + 'images/logoformysite.png',
  link: homeurl + '/' + username + '/something=' + var1 +'&somethingelse=' + encodeURI(var2) + '&evenmore=' + encodeURI(var3),
  description: invitemessage,
});

I had initially had an error last week where if the URL was within the Facebook domain, Facebook would block it. I fixed that and now both the picture and the link do not belong to the Facebook domain and come from my site. But this started happening today with nothing changed. It is intermittent.

An error occurred. Please try again later.

API Error Code: 100 API Error Description: Invalid parameter Error Message: 'link' is invalid.

It is not clear why it works sometimes and not other times even if I am sending it to the same user. Wondering if I missed an announcement. But I would hope that it would at least fail consistently but that is not the case.


UPDATE: I am not sure how the link I am setting in the dialog can be set globally on the page. It will send the recipients of the message the wrong link. It would be really helpful to see an example of how the above would work in the new open graph world.

ANSWER AUG 12 2013

The issue revolved around our url being dynamic and needing force caching each time. I now make an ajax call to "https://developers.facebook.com/tools/debug/og/object" to refresh it and then launch the send dialog.

like image 588
k c Avatar asked Jul 31 '13 22:07

k c


2 Answers

I had the same issue and that stopped working since last week.

Here is my solution:

Go to Facebook debugger and add your URL. Click on "Debug" and fix all warnings displayed by Facebook.

To fix mine I had to add the og.url meta tag in my page. The value should be exactly the same as the one you want to share (no redirection). Then Facebook sent me this notification (alert):

Your app, XXX, is now compliant with the Stream post URL security migration. No further action is required.

Try to share your link with FB.ui once again and now your post should automatically display your og values.

Note: Facebook October breaking change will automatically use those og metas instead of custom FB.ui parameters, therefore you can now activate the breaking change to get ready and remove name/picture/description from your code.

UPDATE: This problem can happens again even if what I mentioned above is correctly implemented.

If it is your case that's because you have to enforce Facebook to "scrape" your page. This process is automatically done by Facebook when you use the Facebook object debugger or you copy/paste your link on your timeline / private messages. If you use the JavaScript SDK you have to ask Facebook to index and cache your page.

You won't find this in the Facebook documentation related to the JavaScript SDK (or you are lucky) so to save you all the days I lost to find this unbelievable issue (remember Facebook only said your link is invalid) you can find more details on this page.

I tried to use the Graph API to enforce my newly created page to be scraped by Facebook, if it works for you you are lucky. The second method which is not mentionned but produced the same result is to send a request to the Facebook Object Debugger page and add your page link in the URL (e.g. https://developers.facebook.com/tools/debug/og/object?q=YourPageUrlHere). By doing this Facebook will this time scrape your page and now you can share your links with the Facebook API, everything is now working.

like image 79
glautrou Avatar answered Sep 29 '22 04:09

glautrou


I can confirm that this was fixed for me when I forced Facebook to first scrape the URL before trying to send that same URL via the FB UI Dialog.

Sample code:

FB.api('https://graph.facebook.com/', 'post', {
    id: '[URL]',
    scrape: true
}, function(response) {
    FB.ui({
        method: 'send',
        name: '[name]',
        picture: '[Picture URL]',
        link: [URL]',
        description: '[description]'
    });
});
like image 39
Scott Avatar answered Sep 29 '22 04:09

Scott