获取facebook用户名

本文关键字:用户 facebook 获取 | 更新日期: 2023-09-27 18:09:08

我需要获得访问我的页面的人的用户名…我遵循以下说明:https://developers.facebook.com/docs/authentication/signed_request/

我写了下面的代码:
string _authorizationUrl = string.Format("https://www.facebook.com/dialog/oauth?client_id={0}&redirect_uri={1}", FB_APPID, Server.UrlEncode(FB_CANVAS_PAGE));
string _signedRequest = Request["signed_request"] as string;
string[] _valuesInRequest = _signedRequest.Split(new char[] {'.'}, 2);
string _stringToDecode = _valuesInRequest[1].Replace("-_","+/");
System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
System.Text.Decoder decoder = encoding.GetDecoder();
byte[] _byteToDecode = Convert.FromBase64String(_stringToDecode);
int charCount = decoder.GetCharCount(_byteToDecode, 0, _byteToDecode.Length);    
char[] _decodedChar = new char[charCount];
decoder.GetChars(_byteToDecode, 0, _byteToDecode.Length, _decodedChar, 0);                   
string result = new String(_decodedChar);

我登录了Facebook,我得到了这个结果:

{"algorithm":"HMAC-SHA256","issued_at":1316602539,"page":{"id":"XXXXXX","liked":false,"admin":false},"user":{"country":"it","locale":"it_IT","age":{"min":21}}}

没有关于用户名的信息。为什么?有人能帮帮我吗?

谢谢

获取facebook用户名

由于隐私问题,这些信息现在没有,而且可能永远不会提供。获取谁正在访问您的Facebook页面的识别信息的唯一方法是让用户使用您的应用程序进行身份验证并获得他们的批准。然后你可以调用/me的图形api来获取它们的id和名称。