我使用以下代码获得了朋友的姓名、头像和 ID,但我需要朋友列表的用户名
protected void Page_Load(object sender, EventArgs e)
{
FaceBookConnect.API_Key = "<App_id>";
FaceBookConnect.API_Secret = "<App_Secret_Id>";
if (!IsPostBack)
{
string code = Request.QueryString["code"];
if (!string.IsNullOrEmpty(code))
{
string data = FaceBookConnect.Fetch(code, "me/friends");
FaceBookData facebookData = new JavaScriptSerializer().Deserialize<FaceBookData>(data);
foreach (FaceBookUser user in facebookData.Data)
{
user.PictureUrl = string.Format("https://graph.facebook.com/{0}/picture", user.Id);
user.Email = string.Format("https://graph.facebook.com/{0}?fields=username", user.Id);
}
gvFriends.DataSource = facebookData.Data;
gvFriends.DataBind();
}
}
}
protected void btnFetch_Click(object sender, EventArgs e)
{
FaceBookConnect.Authorize("user_photos,friends_about_me,friends_photos", Request.Url.AbsoluteUri);
}