Custom post to facebook button
I have a page where users can submit entries to my site, but I want to give them the option to post the entry to facebook as well if a checkbox is checked. They would post a custom message like "[User] has just post on mysite.com" and the caption would be a preview of the entry. My question is how to I publish to a user's facebook stream when they are logged into facebook.
Submit entry:<br />
<textarea name="content" id="content" cols="35" rows="10"></textarea>
<input type="checkbox" name="post" value="fb" /> Post to facebo开发者_如何学Pythonok <br />
I just need to know how to handle what to do when "post" is check. I hope this makes sense.
Also I remember finding a tutorial or something that explained how to do this, but I can't find it anymore.
UPDATE: My site is setup so that when the user logs in with facebook they are prompted to give my site permission to publish to there stream.
You actually need to add a plugin to your website before it would allow users to "authorize" your website to connect with their Facebook account to publish comments or share content directly from your website.
To learn more about making your website more social you should have a look at: Facebook for Websites
Do you mean something like this ? If you have publish.stream permission get the form's response
<script type="text/javascript">
<!--
var body = 'this is the text you want to publish';
FB.api('/me/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
//-->
</script>
Haven't tested it for a while soit might be that you should replace 'me' with the user id.
Good luck Mike
精彩评论