2

我目前正在创建一个添加到 facebook 页面选项卡的应用程序。文档在这里:

http://developers.facebook.com/docs/appsonfacebook/pagetabs/

但是文档没有提到应用程序的回调被删除。当我的应用程序被删除一个我可以用来更新我的记录的选项卡时,是否有这样的回调会提醒我?

如果重要的话,我目前正在使用 PHP。

4

2 回答 2

3

转到您的应用程序:管理页面 -> 编辑设置 -> 高级,然后取消授权回调 URL

这是一个关于如何在我的代码中取消对用户授权的 php 示例:

require_once(dirname(dirname(dirname(__FILE__))).'/autoload.php');
App::init();
DBConn::init();
error_log("request");

$app_secret = 'yoursecretkey';
$request = parse_signed_request($_POST['signed_request'], $app_secret);
$fbid=$request["user_id"];
error_log($fbid);
if ($fbid) {
    $rec = new ADOdb_Active_Record( "users" );
    $found=$rec->load("id=?",array($fbid));
    if ($found){
        $rec->deauth= 1;
        $rec->save();
    }
}
echo "ok";

function parse_signed_request($signed_request, $secret) {
    list($encoded_sig, $payload) = explode('.', $signed_request, 2);

    // decode the data
    $sig = base64_url_decode($encoded_sig);
    $data = json_decode(base64_url_decode($payload), true);

    if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
        error_log('Unknown algorithm. Expected HMAC-SHA256');
        return null;
    }

    // check sig
    $expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
    if ($sig !== $expected_sig) {
        error_log('Bad Signed JSON signature!');
        return null;
    }

    return $data;
}

function base64_url_decode($input) {
    return base64_decode(strtr($input, '-_', '+/'));
}
于 2012-07-30T18:12:44.940 回答
0

I don't believe there is such a callback only one for if the user cancels giving your app the privileges first time around.

When you try to auth the user next time on your site and the auth does not succeed then you know they have either:

  • Deauthed your app
  • Or the fb token has not been used for 60 days

As such the users should reauth your app.

Edit: By site I do mean app. English Fail.

于 2012-07-29T16:54:06.913 回答