如何使用访问令牌获取Facebook用户ID [英] How to get the Facebook user id using the access token

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

问题描述

我有一个Facebook桌面应用程序,并且正在使用 Graph API
我可以获取访问令牌,但在此之后,我不知道如何获取用户的ID。

I have a Facebook desktop application and am using the Graph API. I am able to get the access token, but after that is done - I don't know how to get the user's ID.

我的流程就像这个:


  1. 我将用户发送到 https://graph.facebook.com/oauth/authorize 具有所有必需的扩展权限。

  1. I send the user to https://graph.facebook.com/oauth/authorize with all required extended permissions.

在我的重定向页面中,我从Facebook获取代码。

In my redirect page I get the code from Facebook.

然后,我执行一个HTTP请求到图表oauth / access_token 与我的API密钥,我在响应中获得访问令牌。

Then I perform a HTTP request to graph.facebook.com/oauth/access_token with my API key and I get the access token in the response.

从那里指出我无法获取用户ID。

From that point on I can't get the user ID.

如何解决这个问题?

推荐答案

如果您想使用Graph API获取当前用户ID,那么只需发送请求到:

If you want to use Graph API to get current user ID then just send a request to:

https://graph.facebook.com/me?access_token=...

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

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