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
这是完美的,正是我一直在寻找! – JasonA 2011-04-19 12:24:24