如何使用访问令牌? [英] How to use the access token?

查看:89
本文介绍了如何使用访问令牌?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 javascript (response.authResponse.accessToken)获取访问令牌后如何使用?

How to use the access token after I get it with javascript ( response.authResponse.accessToken ) ?

我希望每个人都可以向朋友发送消息(即使从Facebook注销之后).

I want that everyone can send a message to a friend ( even after logged out from facebook ).

我刚刚尝试了这段代码,但是它不起作用:

I have just tryed this code but it doesn't work:

FB.api('/me?access_token=AAACZBLSe4fcoBAFcGMJZAUS9OthIr5o6ZCUySgXYj0nfWX7u08X7h0VZAFFuJJs9LmeWgud2u5ZCEZCeUHZCVIq1Y2j4gjKAjJ0gx5OY9PBihlABJn64njm', function(response) { });

function sendRequestto() {
      FB.ui({
          method: 'send',
          name: 'hello',
          to: '100000497530558',
          description: 'yuhuuuuuuu'
          });    
}  

并在正文中:

<input type="button" onclick="sendRequestto(); return false;" value="sendRequestto" /> 

推荐答案

像这样:

FB.getLoginStatus(function(response) {
  if (response.status === 'connected') {
     FB.api('/me', function(response) {
       alert('Your name is ' + response.name);
     });
  } else if (response.status === 'not_authorized') {
    // the user is logged in to Facebook, 
    // but has not authenticated your app
  } else {
    // the user isn't logged in to Facebook.
  }
 });

无需显式使用访问令牌.该API会为您做到这一点.

There is no need to use the access token explicitly. The API does that for you.

这篇关于如何使用访问令牌?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆