I'm trying to allow my client's website to share a URL on Facebook that differs from the website's. For example: http://www.example.com has a share link on it for http://www.instagram.com
Whenever I try, I get the following error:
Given URL is not permitted by the Application configuration: One or more of the given URLs is not permitted by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains.
I can't see how I can change my App's settings to allow a different URL to be shared, although I'm guessing it must be possible.
Here's a snippet of my code, to see if that helps:
// Facebook Share
$('#facebook-share').on('click', function(e){
e.preventDefault();
var url = $(this).attr('data-href');
FB.ui({
method: 'share',
href: url
}, function(response){
if (response) {
console.log('Facebook post published.');
} else {
console.log('Facebook post was not published.');
}
});
});
Further research seems to indicate that Facebook Apps can only be used with one URL, no matter what. I changed things to use sharer.php instead:
// Facebook Share
$('.facebook-share').on('click', function(e){
e.preventDefault();
var url = encodeURIComponent($(this).attr('data-href'));
var shareURL = "https://www.facebook.com/sharer/sharer.php?app_id=XXXXXXXX&sdk=joey&u="+url+"%2F&display=popup&ref=plugin&src=share_button";
var width = 655;
var height = 250;
var left = (screen.width/2)-(width/2);
var top = (screen.height/2)-(height/2);
window.open(shareURL, 'facebookShare', 'scrollbars=1,resizable=1,width='+width+',height='+height+',left='+left+',top='+top);
});