Include sentence in facebook post
Hello I want to post a sentence in news feed of user together with the link, but how can I include the text along with th开发者_开发知识库e link. This is the link I am using:
<script type="text/javascript">
function fbs_click() {
u = location.href;
t = document.title; window.open('http://www.facebook.com/sharer.php?u=' + encodeURIComponent(u) + '&t=' + encodeURIComponent(t), 'sharer', 'toolbar=0,status=0,width=626,height=436');
return false;
}
</script>
<style>
html .fb_share_link {
padding:2px 0 0 20px;
height:16px;
background:url(http://static.ak.facebook.com/images/share/facebook_share_icon.gif?6:26981)
no-repeat top left;
}
</style>
<a rel="nofollow" href="http://www.facebook.com/share.php?u=http://www.mywebsite.com" onclick="return fbs_click()" target="_blank" class="fb_share_link">Share on Facebook</a>
Thanks in advance, Laziale
Do you have to use the PHP link? Seems like it might be easier with the official javascript client library: https://github.com/facebook/connect-js . Here is sample code:
FB.ui(
{
method: 'stream.publish',
attachment: {
name: 'JSSDK',
caption: 'The Facebook JavaScript SDK',
description: (
'A small JavaScript library that allows you to harness ' +
'the power of Facebook, bringing the user\'s identity, ' +
'social graph and distribution power to your site.'
),
href: 'http://fbrell.com/'
},
action_links: [
{ text: 'fbrell', href: 'http://fbrell.com/' }
]
},
function (response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
精彩评论