我正在尝试整合facebook登录并在成功登录后从facebook获取个人资料信息,仅使用访问令牌发送回姓名和ID,但不发送电子邮件ID和其他信息。在新的developer.facebook更新发布之前,它工作正常。
下面是获取3周前工作正常的个人资料信息的代码
FaceBookConnect.API_Key = "{app key}";
FaceBookConnect.API_Secret = "{app secret key}";
string code="AQBTVfDZeWbLf3qzYJbexweZJNc-mBl5tPYBx5rIE6GN_0YciFoDajKd3U6jRdtG1vzdxdiieUY2ZFLapY7MLYIXgkHu3ye-ZGVlUZdsbu9GZHlw1rZ9yK8IKJlX20mIp3Qi5TqkA1ODdOEJcst2KlmRTwPUxk7chgfDew8A1R4Bs3A3HFQp23LyCOhgWfQlDwjNaizseBa6FffY7lQlvWpkEncah2_oiY5eZIdv4Iw172ulRcAf4OM824JlM5CmjJUWUyz1hVEAs9OIEvGPKjyW51LMOkoU7fjnOpF7bQtPuHfYRuQjvtsbPnCNx0pC89ndAZvhIKEGWBenN3WFXDdAGS"
string data = FaceBookConnect.Fetch(code, "me");
FaceBookUser faceBookUser = new JavaScriptSerializer().Deserialize<FaceBookUser>(data);
faceBookUser.PictureUrl = string.Format("https://graph.facebook.com/{0}/picture", faceBookUser.Id);
pnlFaceBookUser.Visible = true;
lblId.Text = faceBookUser.Id;
lblUserName.Text = faceBookUser.UserName;
lblName.Text = faceBookUser.Name;
lblEmail.Text = faceBookUser.Email;
ProfileImage.ImageUrl = faceBookUser.PictureUrl;
lblBirthday.Text = faceBookUser.Birthday;
public class FaceBookUser
{
public string Id { get; set; }
public string Name { get; set; }
public string UserName { get; set; }
public string PictureUrl { get; set; }
public string Email { get; set; }
public string Birthday { get; set; }
public string Gender { get; set; }
public FaceBookEntity Location { get; set; }
}
public class FaceBookEntity
{
public string Id { get; set; }
public string Name { get; set; }
}
建议我使用访问令牌获取登录信息的电子邮件ID