Add Share button next to Like and Comment on Facebook Post
facebook, facebook-graph-api, share
Solution
You cannot have share link for feed posts from an application but you can have for link posts as Explained in second example. Or You can also add action links to a post message like this.
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'http://venu.com/',
picture: 'http://venu.com/f8.jpg',
caption: 'Venu site',
description: 'asdasdasdasd.',
message: 'asdasdasd!',
actions: [
{ name: 'share', link: 'link here' }
]
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
Link will be to a custom page in your site/app. Since user is trying to share the messages which was posted by some body else, you should have the message in your server. You can pass the id of the message in the custom URl.
Hope this helps you :)
[EDIT]
or
You can add a link with share button you have to use 'me/links' instead of 'me/feed'. Unfortunately this isnt a complete replacement as Facebook ignores the description, title and picture parameters when using this method. this is bug posted here.(https://developers.facebook.com/bugs/194522957295380)
$attachment = array(
'access_token'=>TOKEN_HERE,
'message'=>'message_here',
'link' => 'http://www.example.com/',
);
$result = $facebook->api(
'me/links',
'post',
$attachment
);
So, now this is similar to having a like button in your site. Facebook pulls the information from open graph meta tags in the given link.
<head>
<meta property="og:locale" content="en_US" />
<meta property="og:site_name" content="name for ENTIRE SITE"/>
<meta property="og:title" content="name of PAGE"/>
<meta property="og:type" content="website"/>
<meta property="og:image" content="<URL HERE>"/>
<meta property="og:description" content="my description" />
<title>Untitled</title>
</head>
Problem
I'm using Facebook's Feed Dialog: http://developers.facebook.com/docs/reference/dialogs/feed/ Whenever I post something using it, Facebook adds 2 links at the bottom (Like and Comment): However, when I see other posts in the Timeline, I also see a "Share" link as well: How can I instruct Facebook to also add this "Share" link through the feed dialog?