I'm trying to use the current (at date of asking this question) Facebook Share Dialog using just the URL (not the SDK).
My JS looks like this:
openFacebookPopup : function (url) {
this.openSharerWindow('https://www.facebook.com/dialog/share' + '?app_id=145634995501895' + '&display=popup' + '&href=http%3A%2F%2Flocalhost' + '&redirect_uri=http%3A%2F%2Flocalhost');
return false;
}
The error I'm getting is:
Could not resolve object at URL
http://localhost/
.
What does that mean and how do I go about trying to resolve it? I should note that this JS does work without problems using the old 'sharer.php' url for facebook.
I've got http://localhost
added into my app.
Since FB can't access to your localhost to feed the popup, you have to feed it yourself.
First, add the Facebook's Javascript SDK on every pages you need it :
window.fbAsyncInit = function() {
FB.init({
appId : 'your-app-id',
xfbml : true,
version : 'v2.3'
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
Then, bind this function on whatever trigger you want, a click event for example :
$('#fb-share-button').click(function() {
FB.ui({
method: 'feed',
link: "The link you want to share",
picture: 'The picture url',
name: "The name who will be displayed on the post",
description: "The description who will be displayed"
}, function(response){
console.log(response);
}
);
});
I console.log the response but in this block you can do what you want. Catch the response to see if the post has been well shared for example.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With