I am using Facebook SDK to load the photos from a specific album like this:
private void LoadAlbum(String albumId)
{
var fb = new FacebookWebClient("token_id");
dynamic albumsPhotos = fb.Get(albumId + "/photos");
List<FacebookImageVo> listOfImages = new List<FacebookImageVo>();
foreach (dynamic imageInfo in albumsPhotos)
{
FacebookImageVo facebookImage = new FacebookImageVo();
if (imageInfo.name != null)
{
facebookImage.Name = imageInfo.name;
}
facebookImage.Id = imageInfo.id;
facebookImage.Source = imageInfo.source;
facebookImage.Picture = imageInfo.picture;
}
rptImages.DataSource = listOfImages;
rptImages.DataBind();
}
I receive a strange error when I try to access name
property of the photo (which I am sure it exists):
'System.Collections.Generic.KeyValuePair<string,object>' does not contain a definition for 'name'
Do you know why?
Solution found:
Instead of:
foreach (dynamic imageInfo in albumsPhotos)
I had to useforeach (dynamic imageInfo in albumsPhotos.data)
to be able to access the properties of the Object.