set user (access token) within FB.init

i want to publish story to user timeline even when they were not login with facebook. Actually I stored user access token in the database, if the user login in with email, i'll retrieve the access token for her. It works well in php (e.g get friends list after setAccessToken(token_from_database), but when i post the story, it always post to current fb login account's timeline.

I think the problem is caused by fb.init:

window.fbAsyncInit = function() {
            appId      : 'XXX', // App ID
            status     : true, // check login status
            cookie     : true // enable cookies to allow the server to access the session
            xfbml      : true  // parse XFBML

and later:


take login account as "me", not the one I set in php through setAcccessToken. How could i post to that account (specify with token_from_database) 's timeline? any idea?


Try passing the access token you want to use as part of the params object you give to FB.api – it should work the same way as it does when accessing the API server-side.

    access_token : 'access_token_for_some_user_fetched_from_your_database',
    additional_parameter_foo : 'bar'

I have more knowledge reagrding the PHP SDK, but in PHP you could just replace the "me" with the user id and I suppose it will work for you as well:


But you should be aware that the access token of the users change, after changing passwords and logging in and out from Facebook.

Need Your Help

Reordering of controls within a flow layout panel

winforms controls combobox flowlayoutpanel

I'm having trouble using the flowlayoutPanel in a C# winform application. What I basically have is a flow layout panel that has 3 sections.