开发者

Facebook c# SDK returning less results than original number

I am getting album photos and there are total of 44 photos in that album but sdk is returning me just 25 results. Is this some limitation or we have to ask for next 25? My code so far is:

dynamic photos = app.Get(AlbumList[currentAlbumSelectedIndex].Id + "/photos");

int infoCount = 0;

foreach (dynamic albumPhoto in photos.data)
{
    Classes.MyPhoto photoData = new Classes.MyPhoto();
    photoData.Id = albumPhoto.id;
    if (albumPhoto.name != null && albumPhoto.name.ToString().Length >100)
        photoData.MyPhotoName = albumPhoto.name.ToString().Substring(0, 90) + "...";
    else
        photoData.MyPhotoName = albumPhoto.name;
    byte[] imageBytes = function.GetImageFromUrl(albumPhoto.source);

    Statuslabel.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate()
    {
        if (imageBytes != null)
            photoData.MyPhotoPicture = function.GetBitmapImage(imageBytes);
        System.Windows.Forms.Application.DoEvents();
        Statuslabel.Content = "Getting info of " + infoCount + " / " + photos.data.Count;
        AlbumPhotoList.Add(photoData);

        if (imageAlbumPhotos.Source == null)
        {
            imageAlbumPhotos.Source = AlbumPhotoList[0].MyPhotoPicture;
            labelAlbumPics.Content = AlbumPhotoList[0].MyPhotoName;
            AlbumPictureGetProgress.Visibility = System.Windows.Visibility.Hidden;
        }
        if (currentAlbumDisplayingPicture < AlbumList开发者_运维百科.Count - 1)
            buttonNextAlbumPic.IsEnabled = true;
    }));

    infoCount++;
}


in your example you are using the method call

app.Get(AlbumList[currentAlbumSelectedIndex].Id + "/photos");

As far as I know, you should be able to pass an IDictionary<string, object> as second parameter. There you define the "offset" parameter.

I read about the offset parameter in the facebook api reference in section Reading > Paging.

Hope this helps, Martin


Well it is not a problem but it is a limit that in order to keep the working efficent it returns only 25 results by default you can ask for as many results.Giving it Offset and limit Values

not the code becomes like this

dynamic parameters = new ExpandoObject();
        parameters.limit = 50;
        parameters.offset = 0;

        dynamic friends = app.Get("me/photos",parameters);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜