Facebook c# SDK 返回的结果少于原始数量

发布于 2024-10-21 09:21:33 字数 1460 浏览 2 评论 0原文

我正在获取相册照片,该相册中共有 44 张照片,但 sdk 仅返回我 25 个结果。这是某种限制还是我们必须要求接下来的 25 个? 到目前为止我的代码是:

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++;
}

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++;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

下雨或天晴 2024-10-28 09:21:33

在您的示例中,您正在使用方法调用

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

据我所知,您应该能够传递 IDictionary 作为第二个参数。您可以在此处定义“偏移”参数。

我在阅读 > 部分中的 facebook api 参考 中阅读了有关 offset 参数的信息寻呼。

希望这有帮助,马丁

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

梦言归人 2024-10-28 09:21:33

好吧,这不是问题,但它是一个限制,为了保持工作效率,它默认只返回 25 个结果,您可以要求尽可能多的结果。给它 Offsetlimit< /code> 值

不是代码变成这样

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

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文