2011-04-19 48 views
2

我試圖從我的個人資料中獲取自己的家鄉信息,但它始終返回null。但是,當我爲我的帳戶獲取圖形API(https://graph.facebook.com/me/?access_token=)時,它會返回到那裏。獲取用戶的家鄉信息

這裏是我的代碼:

SocialMatchUser model = new SocialMatchUser(); 
     var authClient = new FacebookOAuthClient(FacebookApplication.Current) 
     {    
      AppId = appId, 
      AppSecret = appSecret, 
      RedirectUri = new Uri(redirectUrl) 
     }; 

     dynamic token = authClient.ExchangeCodeForAccessToken(Request.QueryString["code"]); 
     var client = new FacebookClient(token.access_token);    
     dynamic me = client.Get("me"); 

     model.ID = Convert.ToInt64(me.id); 
     model.FullName = me.name; 
     model.FirstName = me.first_name; 
     model.LastName = me.last_name; 
     model.Link = me.link; 
     model.UserName = me.username; 
     model.Gender = me.gender; 
     model.Locale = me.locale; 
     model.Birthday = me.birthday; 

     if (me.hometown!= null) 
     { 
      model.HometownId = Convert.ToInt64(me.hometown.id); 
      model.Hometown = me.hometown.name; 
     } 

     return View(model); 

我失去了我的請求或原始身份驗證調用的東西,以允許訪問這些額外的用戶信息?

謝謝! -Jason

回答