尝试了很多方法来使用picasa webalbum和Google驱动器从Google照片中获取照片,但我无法达到结果。请让我知道如何单独获取谷歌照片以及下面的编码显示只有驱动器像Pdf文档等但我需要照片。 ..是否有任何查询我需要实现而不是文件或id。示例编码基于Mac,没有适当的iOS解决方案,XML格式的所有内容请指导我克服这一点。
GTLRDriveQuery_FilesList *query = [GTLRDriveQuery_FilesList query];
query.fields = @"nextPageToken, files(id, name)";
query.pageSize = 10;
[self.service executeQuery:query
delegate:self
didFinishSelector:@selector(displayResultWithTicket:finishedWithObject:error:)];
- (void)displayResultWithTicket:(GTLRServiceTicket *)ticket
finishedWithObject:(GTLRDrive_FileList *)result
error:(NSError *)error
{
if (error == nil)
{
NSMutableString *output = [[NSMutableString alloc] init];
if (result.files.count > 0)
{
[output appendString:@"Files:\n"];
int count = 1;
for (GTLRDrive_File *file in result.files)
{
[FileString appendFormat:@"%@ (%@)\n", file.name, file.imageMediaMetadata];
count++;
NSLog(@"PrintFileString %@",file);
}
} else
{
[output appendString:@"No files found."];
}
self.output.text = output;
} else
{
NSMutableString *message = [[NSMutableString alloc] init];
[message appendFormat:@"Error getting presentation data: %@\n", error.localizedDescription];
[self showAlert:@"Error" message:message];
}
}
答案 0 :(得分:3)
好吧最后我用Google云端硬盘获取谷歌照片,希望这个答案对将来的某些人有用。很多人建议使用Picasa,但我用谷歌驱动器实现了它。我会告诉你步骤
pod 'GoogleAPIClientForREST/Drive', '~> 1.2.1'
@property (nonatomic, strong) GTLRDriveService *service;
GIDSignIn* signIn = [GIDSignIn sharedInstance];
signIn.delegate = self;
signIn.uiDelegate = self;
signIn.scopes = [NSArray arrayWithObjects:kGTLRAuthScopeDrivePhotosReadonly, nil];
[signIn signInSilently];
// Initialize the service object.
self.service = [[GTLRDriveService alloc] init];
self.service.shouldFetchNextPages = YES;
- (void)signIn:(GIDSignIn *)signIn
didSignInForUser:(GIDGoogleUser *)user
withError:(NSError *)error
{
if (error != nil)
{
self.service.authorizer = nil;
}
else
{
self.service.authorizer = user.authentication.fetcherAuthorizer;
[self listFiles];
}
}
// Google照片是Nsmutablearray
- (void)listFiles
{
GTLRDriveQuery_FilesList *query = [GTLRDriveQuery_FilesList query];
query.q = @"mimeType='image/jpeg'";
query.spaces = @"photos";
query.pageSize = 200;
query.fields = @"nextPageToken,files(id,name,mimeType,thumbnailLink,originalFilename)";
[self.service executeQuery:query completionHandler:^(GTLRServiceTicket *ticket,
GTLRDrive_FileList *result,
NSError *error)
{
if (error == nil)
{
[GooglePhotos removeAllObjects];
for (GTLRDrive_File *fileInput in result.files)
{
[SVProgressHUD show];
NSMutableDictionary*Mydiction=[[NSMutableDictionary alloc]init];
[Mydiction setObject:fileInput.thumbnailLink forKey:@"IMAGEURL"];
[Mydiction setObject:fileInput.identifier forKey:@"UNIQUEKEY"];
[Mydiction setObject:fileInput.originalFilename forKey:@"ORIGINALFILENAME"];
[Mydiction setObject:fileInput.name forKey:@"NAME"];
[Mydiction setObject:fileInput.mimeType forKey:@"MIMETYPE"];
[GooglePhotos removeObject:Mydiction];
[GooglePhotos addObject:Mydiction];
// NSLog(@"PrintDetails %@",GooglePhotos);
}
[SVProgressHUD dismiss];
} else
{
NSLog(@"An error occurred: %@", error);
}
}];
}