Facebook c# SDK 返回的结果少于原始数量
我正在获取相册照片,该相册中共有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的示例中,您正在使用方法调用
据我所知,您应该能够传递
IDictionary
作为第二个参数。您可以在此处定义“偏移”参数。我在阅读 > 部分中的 facebook api 参考 中阅读了有关 offset 参数的信息寻呼。
希望这有帮助,马丁
in your example you are using the method call
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
好吧,这不是问题,但它是一个限制,为了保持工作效率,它默认只返回 25 个结果,您可以要求尽可能多的结果。给它
Offset
和limit< /code> 值
不是代码变成这样
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
andlimit
Valuesnot the code becomes like this