Reputation: 1798
I know that this question was asked a lot of times, but still I can find deprecated solutions or solutions that mix logins and authentications (which is not needed in my case).
I was wondering which is the fastest (and smartest) way of sharing a website link on Facebook using either Java or Javascript. I just want to post the message:
You scored 9/10 on the game: <link>
I think a clear HowTo would be of great help to me and other people fighting with the same dilemma :)
Thanks in advance.
Upvotes: 0
Views: 3534
Reputation: 291
If you want to use javascript
you need to include Facebook javascript SDK
to your site. This is how you should add Facebook Javascript SDK.
Example for adding to post to your wall.
function(message, name, pictures, description, link) {
FB.api('/me/feed', 'post', {
message: message,
name: name,
picture: picture,
description: description,
link: link
}, function (result) {
var retVal = true;
if (result) {
console.log('Facebook API: Send Status: Success');
}
else {
console.log('Facebook API: Send Status: Failed');
retVal = false;
} return retVal;
});
}
This solution does not include user action it can be done in background. Only thing that is needed is that is user logged on Facebook, and you have application on Facebook.
Upvotes: 0
Reputation: 4638
You could use simple JS
<a href="#"
onclick="
window.open(
'https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href),
'facebook-share-dialog',
'width=626,height=436');
return false;">
Share on Facebook
</a>
Upvotes: 2