Facebook 帐户取消链接或取消授权 Facebook 应用程序并检查 Facebook 应用程序的链接状态

发布于 2024-12-24 01:18:17 字数 274 浏览 2 评论 0原文

我的网站应用程序具有通过 Facebook 登录进行登录的功能。为此,我的应用程序出现在 Facebook 上。使用 Facebook 登录工作正常。

但应用程序具有将 Facebook 帐户链接和取消链接到 Facebook 应用程序的功能。

  • 如何检查 FB 帐户是否与特定 FB 应用程序关联?
  • 如果已链接(根据该用户的请求),如何取消 FB 帐户与特定 FB 应用程序的链接?

(“链接”意味着我们根据要求选择“允许”FB 应用程序)

My website application having feature login with Facebook login. And for which my app is present on Facebook. Login with facebook is working fine.

But application have feature of linking and unlinking facebook account to Facebook app.

  • How to check FB account is linked with specific FB app or not?
  • And how to unlink FB account from specific FB app if linked (On that user's request )?

("Linked" means we select "Allow" to FB app on request)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

童话里做英雄 2024-12-31 01:18:17

对于新的 Graph,有一种记录在案的取消授权方法(我已经在 Graph API 资源管理器中对其进行了测试,并且它有效)。使用有效的访问令牌向“me/permissions”发送 HTTP 删除命令。它不仅会使访问令牌失效,还会从用户的身份验证应用程序列表中删除该应用程序。这需要用户再次授权应用程序(通过权限屏幕)才能使用它。快乐编码!

With the new Graph there is a documented way to deauthorize (I've tested it in the Graph API explorer and it works). Send an HTTP Delete command to "me/permissions" with a valid access token. Not only will it invalidate the access token, but it also removes the app from the user's list of auth apps. This requires the user to authorize the app again (going thru the permissions screens) to use it. Happy coding!

辞别 2024-12-31 01:18:17

请注意 Facebook 正在弃用 REST API,并为 Graph API 用户对象添加了对“auth.revokeAuthorization”方法的等效支持。

//$this->facebook is facebook object
//$userid is of logged in user or can be written hardcoded.
For checking linked in or not by making api call.

        $user_id = $this->facebook->getUser();
        $result = $this->facebook->api(array(
                'method' => 'fql.query',
                'query' => "SELECT is_app_user FROM user WHERE uid=$user_id"
        ));
        $is_installed = $result[0]['is_app_user'];
        if($is_installed==1) {
            echo 'Linked';
        }
        else {
            echo 'Not Linked';
        }


For delinking or deauthorization the user by making app call:

        $user_id = $this->facebook->getUser();
        $access_token=$this->facebook->getAccessToken();
        $result = $this->facebook->api(array(
                'method' => 'auth.revokeAuthorization',
                'uid' =>$user_id,
                'access_token'=>$access_token
        ));

Please note Facebook in the process of deprecating the REST API, and have adding equivalent support to the Graph API User object for "auth.revokeAuthorization" method.

//$this->facebook is facebook object
//$userid is of logged in user or can be written hardcoded.
For checking linked in or not by making api call.

        $user_id = $this->facebook->getUser();
        $result = $this->facebook->api(array(
                'method' => 'fql.query',
                'query' => "SELECT is_app_user FROM user WHERE uid=$user_id"
        ));
        $is_installed = $result[0]['is_app_user'];
        if($is_installed==1) {
            echo 'Linked';
        }
        else {
            echo 'Not Linked';
        }


For delinking or deauthorization the user by making app call:

        $user_id = $this->facebook->getUser();
        $access_token=$this->facebook->getAccessToken();
        $result = $this->facebook->api(array(
                'method' => 'auth.revokeAuthorization',
                'uid' =>$user_id,
                'access_token'=>$access_token
        ));
陌上青苔 2024-12-31 01:18:17

这可以通过简单的 FQL 查询轻松实现:

SELECT uid FROM user WHERE uid = {USER_ID_HERE} AND is_app_user = true

如果用户与应用程序连接,则将返回用户的 uid,否则不会返回任何内容

This can easily achieved with simple FQL query:

SELECT uid FROM user WHERE uid = {USER_ID_HERE} AND is_app_user = true

This will return uid of user if he is connected with app and nothing otherwise

在风中等你 2024-12-31 01:18:17

使用您的应用访问权限对 /{USER_ID}/permissions 进行 API 调用令牌,它将显示该用户是否已授权您的应用程序。

您还可以检查用户的访问令牌(如果有)。

响应类型将如下所示:

{
  "data": [
    {
      "installed": 1, 
      "bookmarked": 1
    }
  ] 
}

对于用户授予您的应用程序的每一项扩展权限,都会有一个条目,并且 installed 行意味着他们已经安装了您的应用程序

对于尚未安装的用户如果没有安装您的应用程序,则响应将是:

 {
   "data": [  
   ]
 }

您还可以使用 FQL,如 Juicy Scripter 在另一个答案中建议的那样

Make an API call to /{USER_ID}/permissions with your App access token and it will show if that user has authorised your app

You can also check with the user's access token if you have one.

The response type will be something like this:

{
  "data": [
    {
      "installed": 1, 
      "bookmarked": 1
    }
  ] 
}

There'll be one entry there for each extended permission the user has granted your app and the installed line means they've installed your app

For a user who hasn't installed your app the response will be:

 {
   "data": [  
   ]
 }

You can also use FQL as Juicy Scripter suggests in another answer

对风讲故事 2024-12-31 01:18:17

以下是如何使用 Facebook iOS SDK v4 取消对应用程序的授权:

#import <FBSDKCoreKit/FBSDKCoreKit.h>

...

NSString *graphPath = [NSString stringWithFormat:@"/%@/permissions", [FBSDKAccessToken currentAccessToken].userID];
[[[FBSDKGraphRequest alloc] initWithGraphPath:graphPath parameters:nil HTTPMethod:@"DELETE"]
    startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    if ( !error ) {
        NSLog(@"Facebook unlinked");
    }
}];

Here's how to deauthorize your app using Facebook iOS SDK v4:

#import <FBSDKCoreKit/FBSDKCoreKit.h>

...

NSString *graphPath = [NSString stringWithFormat:@"/%@/permissions", [FBSDKAccessToken currentAccessToken].userID];
[[[FBSDKGraphRequest alloc] initWithGraphPath:graphPath parameters:nil HTTPMethod:@"DELETE"]
    startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
    if ( !error ) {
        NSLog(@"Facebook unlinked");
    }
}];
小瓶盖 2024-12-31 01:18:17

通过 Graph API,来自文档(感谢@DMCS):

您可以取消对应用程序的授权或撤销特定的扩展
通过向以下用户发出 HTTP DELETE 请求来代表用户授予权限
PROFILE_ID/该应用程序的用户 access_token 的权限。

旧的 REST API 为您提供 auth.revokeAuthorization。您可以在auth.revokeAuthorization 文档上了解更多相关信息。

请注意,REST API 将来将会被弃用,尽管 Facebook 没有具体说明何时弃用。

我不知道有什么方法可以获取给定用户所连接的应用程序列表,也不知道 Facebook 提供该列表的任何原因。要查看用户是否连接到您的应用程序,此处的其他答案应该可以为您提供一些想法。

Through the Graph API, from the docs (thanks @DMCS):

You can de-authorize an application or revoke a specific extended
permissions on behalf of a user by issuing an HTTP DELETE request to
PROFILE_ID/permissions with a user access_token for that app.

The olds REST API offers you auth.revokeAuthorization. You can read more about that on the auth.revokeAuthorization docs.

Be aware that the REST API will be deprecated in the future, although Facebook doesn't specify when exactly.

I am not aware of any way to get a list of apps a given user is connected to, or see any reason Facebook would make that available. To see if a user is connected to your app, the other answers here should provide you with a couple of ideas.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文