![](/img/trans.png)
[英]Cannot Get Facebook Profile Picture Using www in Unity Facebook SDK
[英]Unity : Get Facebook email by Facebook SDK
我使用Facebook SDK進行我的應用登錄,並嘗試訪問ID,名稱和電子郵件。 我遵循來自Facebook開發人員FB.LogInWithReadPermissions的參考
public void FBLogin(){
FB.LogInWithReadPermissions (new List<string>(){"public_profile","email","user_friends"}, AuthCallback);
}
private void AuthCallback (ILoginResult result) {
if (FB.IsLoggedIn) {
// AccessToken class will have session details
var aToken = Facebook.Unity.AccessToken.CurrentAccessToken;
// Print current access token's User ID
// Print current access token's granted permissions
foreach (string perm in aToken.Permissions) {
Debug.Log(perm);
}
FB.API ("/me?fields=id,name,email",HttpMethod.GET, GetFacebookInfo);
} else {
Debug.Log("User cancelled login");
}
}
public void GetFacebookInfo(IResult result){
if (result.Error == null) {
Debug.Log (result.ResultDictionary ["id"].ToString ());
Debug.Log (result.ResultDictionary ["name"].ToString ());
Debug.Log (result.ResultDictionary ["email"].ToString ());
} else {
Debug.Log (result.Error);
}
}
我在Debug.Log (result.ResultDictionary ["email"].ToString ());
得到錯誤Debug.Log (result.ResultDictionary ["email"].ToString ());
KeyNotFoundException: The given key was not present in the dictionary.
我錯過了什么 ? 如何獲得電子郵件。 非常感謝。
嘗試換線
FB.API ("/me?fields=id,name,email",HttpMethod.GET, GetFacebookInfo);
成
FB.API ("/me?fields=id,name,email", HttpMethod.GET, GetFacebookInfo, new Dictionary<string, string> () { });
我記得有同樣的錯誤,它為我工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.