开发者

Using Javascript and Facebook Graph API

开发者 https://www.devze.com 2023-01-10 08:51 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消