English 中文(简体)
取消Facebook访问标记吗?
原标题:Invalidating a facebook access token?

能否取消Facebook访问标记?

我需要这样做,因为最近 离线接入的折旧。

问题在于该标记不能延长到60天以上。 即使用户返回应用程序( 除非我误解吗? ) 。

所以,我想做的是无效的标记, 然后立即将用户登录回去, 这样我就可以重新获得一个新的访问标记, 新的60天过期日期。 只要用户每两个月来一次, 一切都会好起来 。

我不想在Facebook上登录用户, 因为FB. logout 无法使用 。

有可能吗?

最佳回答

您可以向 /me/permissions 发送 DELETE 请求,该请求应该(我认为)使会话对用户无效。

However, I don t really see why you want to do that. You can just use the server side authentication which ends up with a 60 days token regardless of what token you had before. So, every time you want 60 more days just authenticate the user using the server side process.

问题回答

我将认真考虑避免Facebook Javascript SDK 像瘟疫一样, 因为它在现实中是惊人的,

我刚刚开始重建我的登录流程, 我想知道我的代码的这一部分 是否对管理用户标志有用:

if ($user) {
  try {
    // Proceed knowing you have a logged in user who s authenticated.
    $user_profile = $facebook->api( /me );
  } catch (FacebookApiException $e) {
    $fb_error = $e->getResult();
    error_log($e);
    $user = null;
  }
}


//https://developers.facebook.com/docs/reference/api/errors/
switch ($fb_error[ error ][ error_subcode ]) {
    case  458 :
    //Returned on app trying something or user attempting an action after app deauth
    //Can do database cleannup operations from this
        $fb_error =  458 - User removed the app from user settings ;
        break;
    case  460 :
    //App is no longer reauthorized and the user is trying something ?
    //Stop user from all activities if this comes up as they may deauth then try perform an action
        $fb_error =  460 - User needs to reauthorize ;
        break;
    case  463 :
    //Expired Token
    //This is where we autolog the user back in
        $fb_error =  463 - Token has expired and a new one needs to be requested ;
        //need to somehow get the login request code from another page to hide it
        //or use htaccess tricks
        $facebook->getAccessToken();
        break;
    case  467 :
    //Invalid Token
    //This is where we autolog the user back in
        $fb_error =  467 - Token is invalid and a new one needs to be requested ;
        break;
}

您可以将错误输出到页面进行测试 :

echo  Error Subcode:  .$fb_error. <br/> ;
echo  Facebook Error Dump:<br/> ;
var_dump($e);

请注意, PHP 开关工作就像一个有多个答案的单 < code> if 语句( 案例 ) 。

我建议代码速度优化重新排序开关, 以在开关顶部列出最常见的错误, 因为 PHP 开关的工作方式是向列表下运行, 直到找到一个与错误代码匹配的大小写 。

根据脸书","https://developmenters.facebook.com/roadmap/offline-access-remotion/"rel="nofollow">文件 ,你不需要做任何复杂的事情。

在用户登录过程中,取回一个短期存取标记,并换成一个60天有效长期存取标记。

如果用户在白天多次登录和日志, 他将得到相同的访问标记( 可能), 但过期时间将无法更新 。 但至少过了一天后, 您将收到新的长寿访问标记, 并有新的过期时间 。

唯一可能的问题就是用户经常登录超过两个月(超过60天)的假想。 对于这些假想(即使这几乎是不可能的),我对一个小的超时功能进行编码,当象征性失效时,它会在背景中更新。

我重构了昨天下午用来取回和使用长寿的象征物的密码, 所以它没有经过足够的时间来确切地说, 但是根据上面提到的Facebook文件, 它应该是那样的。

您不需要将访问标记无效 。

如果您使用一个 < 坚固> 新的 < / 坚固 > 短寿命存取标记来交换它, 将会返回一个新的60天扩展标记。 当用户再次使用该应用程序时, 此特定短寿命标记总是给予您 。 使用客户端的验证流( JSSSSDK), 这样您就能确定您得到了短寿命标记 。 使用新的端点来替换标记 。

更多信息请查看"facebook doc





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签