我正在尝试在桌面上使用 C# 开发一个应用程序,其中一个用户正在通过电子邮件或姓名搜索一个人。然后它会列出用户的信息和公共相册或图片。然后程序的用户会看照片,如果能找到合适的搜索人会添加朋友。
我的问题是我无法列出和显示公共相册。我尝试使用 FQL 和图形 API,但都返回了空数据。我为此编写的代码:
ArrayList pictureLink;
public void userPhotos(string userID)
{
var fb2 = new FacebookClient(_accessToken);
//result1 and result2 aren't using in code only for looking for with breakpoint
dynamic result1 = fb2.Get("fql", new { q = "SELECT aid,cover_pid FROM album WHERE owner=" + kisiID });
dynamic result2 = fb2.Get("fql", new { q = "SELECT pid,aid FROM photo WHERE owner=" + kisiID });
ArrayList imageSize; //for gettig highest pixell of picture
pictureLink = new ArrayList();
var fb = new FacebookClient(_accessToken);
//dynamic albums = fb.Get("me/albums"); // THİS code is rigth runnig
dynamic albums = fb.Get(userID + "/albums");
foreach (dynamic albumInfo in albums.data)
{
//Get the Pictures inside the album this gives JASON objects list that has photo attributes
// described here http://developers.facebook.com/docs/reference/api/photo/
dynamic albumsPhotos = fb.Get(albumInfo.id + "/photos");
foreach (dynamic rs in albumsPhotos.data)
{
imageSize= new ArrayList();
foreach (dynamic rsa in rs.images)
{
imageSize.Add(rsa.height);
}
int highestImage = Convert.ToInt32(imageSize[0]);
foreach (dynamic rsa in rs.images)
{
if (rsa.height == highestImage )
{
string link= rsa.source;
pictureLink.Add(link);
}
}
}
}
}