Publish to wall with Facebook API
I would like users to be able to post to their wall from my site. When I click on my submit to FB link, the Facebook popup just says "An Error Occurred. Please try again later." Firebug just says that the error is "Image corrupt or trunca开发者_C百科ted: ". I get this same message if try any FB method, like FB.login or FB.getLoginStatus. I know that's not a lot to go off of, but does anyone have ideas for what's going wrong, or a better way to debug this?
function load_FB(){
FB.init({
appId : xxxxxxxxxxxxxxxx,
status : true,
cookie : true,
xfbml : true
});
}
var publish = {method: 'feed', message: 'my message'};
function publish_wall_post()
{
FB.ui(publish);
}
Take a look at the FB.ui docs at https://developers.facebook.com/docs/reference/javascript/FB.ui/
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
message: 'Facebook Dialogs are easy!'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
thinkdiff has a great working example on how to publish on a wall. http://thinkdiff.net/facebook/graph-api-iframe-base-facebook-application-development/
精彩评论