简体   繁体   中英

Using Javascript and Facebook Graph API

I'm trying to publish to another user wall, so it would appear as if HE published 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM