我正在尝试使用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);
}
}
}
}
}
答案 0 :(得分:0)
要阅读您需要的相册:
- 任何有效的访问令牌(如果它是公共的并且属于Page
)- user_photos权限(如果它属于用户
)- 如果friend_photos属于用户的朋友
,则该权限
来源:https://developers.facebook.com/docs/reference/api/album/
您需要的是以下声明,列表中不。
- 任何有效的访问令牌(如果它是公共的并且属于用户
)
这意味着API只是让您无法访问公开相册。它与events相同。