Using Javascript and Facebook Graph API
I'm trying to publish to another user wall, so it would appear as if HE p开发者_开发百科ublished this post himself. For example, I want to write "I've published a new article on Youngo.com" on his wall.
I have an offline access and stream publish permissions. I also got the access token. I just can't figure how to do that using JavaScript.
Do you mean something like this:
var wallPost = {
access_token: "<ACCESS_TOKEN>",
message: 'Hello, World!'
};
FB.api('/<UID>/feed', 'post', wallPost, function(response) {
if (!response || response.error) {
alert('Error occurred');
} else {
alert('Success!');
}
});
If you are trying to post to FB's API directly from javascript it won't work. You have to wrap their api with a web service on your domain since javascript isn't allowed to do cross domain requests.
精彩评论