如何通过javascript接收返回扩展访问令牌

时间:2012-07-09 17:44:11

标签: facebook-javascript-sdk facebook-access-token

延伸后,我可以:

  1. 请参阅浏览器上的扩展访问令牌: access_token = TOKEN& expires = EXPIRES
  2. 错误消息“左侧无效分配”
  3. 如何从响应中获取令牌。

    我的代码:


    <script>
          window.onload = function() {
    
                FB.init({appId:422642254433770, cookie:true, status:true, xfbml:true });
    
                FB.getLoginStatus(function(response) {
                    var uid = response.authResponse.userID;
                    var accessToken = response.authResponse.accessToken;
                    var accessTokenOld = response.authResponse.accessToken;
    
                    //Extend access token                    
                    var OauthParams = {};
                    OauthParams['client_id'] = 'CLIEN ID';
                    OauthParams['client_secret'] = 'CLIENT SECRET';
                    OauthParams['grant_type'] = 'fb_exchange_token';
                    OauthParams['fb_exchange_token'] = accessToken;
                    OauthParams['response_type'] = 'token';
    
                    FB.api('/oauth/access_token', 'post', OauthParams, function(extendResponse) {
                        console.log("Extend token: " + extendResponse.accessToken);
                    });  
                });
            };
    
    </script>
    

0 个答案:

没有答案