2011-09-21 122 views
0

我需要讓人們帳號正在訪問我的網頁...我按照以下istructions: https://developers.facebook.com/docs/authentication/signed_request/獲取Facebook的用戶名

伊夫寫下面的代碼:

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}}} 

沒有信息aabout用戶名。爲什麼?任何人都可以幫我嗎?

謝謝

回答

1

這個信息是不是,而且可能永遠不會是,可由於隱私問題。獲取關於誰訪問您的Facebook頁面的信息的唯一方法是讓用戶通過您的應用程序進行身份驗證並讓他們批准。然後,您可以在/我/圖上調用圖表API來獲取它們的ID和名稱。