views:

78

answers:

2

Hi,

I have just used the javascript sdk to publish to the wall when the user is online.

I am starting to like it. Now I want to post to wall when user is offline. I already have extended permissions from the user.

How can I post to user's wall when user is offline using javascript sdk.

here is my code:

function Publish(body){
        FB.api('/me/feed', 'post', { message: body }, function(response) {
            if (!response || response.error) {
                 alert('Error occured');
            } else {
                 alert('Post ID: ' + response.id);
            }
       });
 }

I appreciate any help.

Thanks.

+3  A: 

That's only possible when user permits you. In other words, you need offline_access extended permission from user and only after that you can do that.

Sarfraz
I have extended permissions from the user but i dont know how to post is it same as when user is online.
Melanie W
@Melanie W: You should post your code also.
Sarfraz
@sAc I have updated my code.
Melanie W
@Melanie W: But where are you specifying the userid of the user to whom you want to send the wall post in your code?
Sarfraz
@sAc I use javascript sdk /me/feeds implies the logged in user. I dont use userid. But I have the user id of the user if you want.
Melanie W
@Melanie W: Once user has given you offline access, you should use his userid instead of me/feeds
Sarfraz
it does not work.
Melanie W
@Melanie W: What error do you get?
Sarfraz
A: 

I'm not 100% sure of this, but I don't believe you can accomplish this with only the JavaScript API.

Just getting the user to accept the permissions isn't enough - that doesn't make all your API calls "automagically" work. As mentioned in item #3 here, you are given an access_token that is to be used in future API calls on behalf of the user.

And so enters the problem with the offline_access permission. If using JavaScript only - where are you going to store the access token that grants offline access so that you may use it when the user is not at their computer?

If even you figured out how to store it and retrieve it for later use, I'm not sure if you can even use the JavaScript SDK to make API calls for a non-session user.

Peter Bailey