OneDrive api get all photos

Pls can someone help me with live api. I need to get all the photos from OneDrive. I do not want to use "/ me / albums" and then use other methods to call the album. There is a somu method for this. Am I missing something? I'm trying google but the links are dead.

Thank you

+4
source share
2 answers

It might be worth starting with a sample of PhotoSky on Github that gets all the custom photos. Take a look at the code in the "Data Model" as it has functions for loading data from an album, for example:

public async void LoadData()
    {
       LiveConnectClient client = new LiveConnectClient(App.Session);

        LiveOperationResult albumOperationResult = await client.GetAsync("me/albums");
        dynamic albumResult = albumOperationResult.Result;
        foreach (dynamic album in albumResult.data)
        {
            var group = new SkyDriveAlbum(album.id, album.name, album.name, @"ms-appx:///Assets/DarkGray.png", album.description);
            LiveOperationResult pictureOperationResult = await client.GetAsync(album.id + "/files");
            dynamic pictureResult = pictureOperationResult.Result;
            foreach (dynamic picture in pictureResult.data)
            {
                var pictureItem = new SkyDriveItem(picture.id, picture.name, picture.name, picture.source, picture.description, picture.description, group);
                group.Items.Add(pictureItem);
            }
            this.AllGroups.Add(group);
        }
    }
+1

Live API, , , . ,

USER_ID/skydrive/camera_roll - OneDrive. USER_ID/skydrive/my_photos "".

, API OneDriveSDK, .

- (void)getPhotos {
    ODDriveAllPhotosRequest *allPhotosRequest = [[self.client.drive allPhotos] request];
    if (![self.client serviceFlags][@"NoThumbnails"]){
        [allPhotosRequest expand:@"thumbnails"];
    }
    [self loadPhotosWithRequest:allPhotosRequest];

}

- (void)loadPhotosWithRequest:(ODDriveAllPhotosRequest *)allPhotosRequest {
   [allPhotosRequest executeWithCompletion:^(ODCollection *response, ODDriveAllPhotosRequest *nextRequest, NSError *error) {
    if (!error){
        if (response.value){
            [self onLoadedPhotos:response.value];
        }
        if (nextRequest){
            [self loadPhotosWithRequest:nextRequest];
        }
    }
    else if ([error isAuthenticationError]){
        [self showAlert:@"isAuthenticationError" message:error.localizedDescription];
        [self onLoadedPhotos:@[]];
    }
    DDLogError(@"response %@ \n next request %@ \n error:%@",response,nextRequest,error);
    }];
}

- (void)onLoadedPhotos:(NSArray *)photos
{
  [photos enumerateObjectsUsingBlock:^(ODItem *item, NSUInteger index, BOOL *stop){
  }];
}
0

Source: https://habr.com/ru/post/1538471/


All Articles