Facebook c#SDK返回的结果少于原始数字
我收到了相册照片,相册中总共有44张照片,但sdk只返回了25张结果。这是某种限制还是我们必须要求下一个25? 到目前为止,我的代码是:Facebook c#SDK返回的结果少于原始数字,c#,wpf,facebook-graph-api,facebook-c#-sdk,C#,Wpf,Facebook Graph Api,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
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++;
}
dynamic photos=app.Get(相册列表[currentAlbumSelectedIndex].Id+“/photos”);
int infoCount=0;
foreach(photos.data中的动态相册照片)
{
Classes.MyPhoto photoData=新类.MyPhoto();
photoData.Id=albumPhoto.Id;
if(albumPhoto.name!=null&&albumPhoto.name.ToString().Length>100)
photoData.MyPhotoName=albumPhoto.name.ToString().子字符串(0,90)+“…”;
其他的
photoData.MyPhotoName=albumPhoto.name;
byte[]imageBytes=function.GetImageFromUrl(albumPhoto.source);
Statuslabel.Dispatcher.Invoke(DispatcherPriority.Normal,新操作(委托)()
{
if(imageBytes!=null)
photoData.MyPhotoPicture=function.GetBitmapImage(imageBytes);
System.Windows.Forms.Application.DoEvents();
Statuslabel.Content=“获取“+infoCount+”/“+photos.data.Count”的信息;
相册照片列表。添加(照片数据);
if(imageAlbumPhotos.Source==null)
{
imageAlbumPhotos.Source=AlbumPhotoList[0]。MyPhotoPicture;
labelbumpics.Content=AlbumPhotoList[0]。MyPhotoName;
AlbumPictureGetProgress.Visibility=System.Windows.Visibility.Hidden;
}
如果(currentAlbumDisplayingPicture
在您的示例中,您正在使用方法调用
app.Get(AlbumList[currentAlbumSelectedIndex].Id + "/photos");
据我所知,您应该能够将IDictionary
作为第二个参数传递。在这里定义“偏移”参数
我在Reading>Paging一节中了解了有关偏移量参数的内容
希望这会有所帮助,Martin这不是问题,但为了保持工作效率,默认情况下,它只返回25个结果,您可以请求尽可能多的结果。给它
偏移量
和限制值
代码不是这样的
dynamic parameters = new ExpandoObject();
parameters.limit = 50;
parameters.offset = 0;
dynamic friends = app.Get("me/photos",parameters);
这就是说,如果我们使用DotnetFramework4,我们可以省略IDictionary,这会使它变得简单