How do I renew a Facebook user_access_token if I deal with a lot of AJAX?

后端 未结 7 1087

Please tell me if I\'m understanding correctly. (because I might not be.)

  1. User posts something on my site. (He checked \"also post to Facebook\".)
  2. Client
7条回答
  •  生来不讨喜
    2021-02-09 13:22

    Before posting to the server, call FB.getLoginStatus() on the client to get the latest access token. There is no flash when using this method and no user interaction, as it simply grabs a new access token.

    FB.getLoginStatus( function ( response ) {
        if ( response.authResponse ) { 
            var accessToken = response.authResponse.accessToken;
            //post to server
        };
    } );
    

提交回复
热议问题