Here is the code I am using to get Facebook friend list, the class
public class FBUser
{
public long Id { get; set; }
public string Username { get; set; }
public string Name { get; set; }
public string Link { get; set; }
public string Picture { get; set; }
// empty constructor
public FBUser()
{ }
}
the list class
public class FbFriendList
{
public WcdyList<FBUser> Data { get; set; }
}
and here is the method I am using to get the friend list:
try
{
FacebookClient client = new FacebookClient(accesstoken);
FbFriendList myfriends = client.Get<FbFriendList>("me/friends?fields=id,name,username,picture,link");
if (myfriends.Data.Count > 0) return myfriends.Data;
else return null;
}
catch (Exception ex) { }
myfriends is returning the data object null, can you please tell me what I am doing wrong here?
You can use code like this to get the friends info
Now you can map the resulting data to your custom classes…
Update:
Seems like you using
Datainstead ofdata(you should stick to original names of fields in response)Update2:
You can loop over the list to get friends details like this:
Or like this if you not yet on .net4: