1.Create a javascript function:
function sharePost() {
FB.ui(
{
method: 'stream.publish',
attachment: {
name: 'test',
media:[{type:'image',src:'logo.jpg',href: 'www.facebook.com/test'}],
description: ('Test.' ),
href: 'http://www.facebook.com/pages/test/11111111?sk=app_111111111'
}
});
return false;
}
2. Add click event to the a tag.
<a href="#" onclick="sharePost(); return false;" >button</a>
3. Add facebook init.
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: "11111111",
status: true,
cookie: true,
xfbml: true});
FB.Canvas.setSize({width: 520, height: 1200});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
3. Add facebook init.
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({appId: "11111111",
status: true,
cookie: true,
xfbml: true});
FB.Canvas.setSize({width: 520, height: 1200});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
No comments:
Post a Comment