views:

166

answers:

2

Hello,

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.

Can someone help please?

Thanks in advanced! :)

A: 

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.

Achilles
I can publish to my own stream or make my website publish to the current user's session (as long as he has given the right permissions...) so why can't I publish on the other user's behalf If I have his access token?
Omri Soudry
JSON-P enables cross domain requests everywhere. Modern browsers (IE8+, FF3, Chrome, Safari) also enable this natively. Flash also helps.
daaku
I don't think JSONP is needed when the JavaScript is loaded from the same domain to which the external calls are made too (by that JavaScript).
Anurag
+1  A: 

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!');
    }
});
serg
Yes, but I get an 'error occured' message when I try this
Omri Soudry
@Omri what error are you getting exactly? dump the response into firebug console.
serg
When the token is mine and the UID is "me" - That works.But if I change the token and the UID to another user, it alerts me with an error. What can I use to see the full error details?
Omri Soudry
@Omri well if you don't have firebug then at least do `alert(response.error);`, if you do have firebug then `console.log(response);`
serg
It just says: object Object
Omri Soudry
@Omri it returns some error code inside that object, you need to read it somehow. If you don't know a better way then go grab firebug, it would save you lot of time. If you have Chrome you can also use `console.log` to explore all fields of an object.
serg
I think i figured the problem out...Something was wrong with the permissions...Does someone knows how to check and ask for permissions using JavaScript?
Omri Soudry
@Omri: http://developers.facebook.com/docs/reference/javascript/FB.login
serg
Thanks a lot!And I also didn't find a way to delete posts from another user wall. The examples on the Facebook Developers area doesn't show that...Can someone please help?
Omri Soudry