是否可以从我的gmail帐户下载文档到iphone应用程序的documents文件夹。实际上,我使用了Google Doc API,并通过使用
-(GDataServiceGoogleDocs *)getdocservice
{
static GDataServiceGoogleDocs *docs = nil;
if(!docs)
{
docs = [[GDataServiceGoogleDocs alloc]init];
[docs setShouldCacheResponseData:YES];
[docs setServiceShouldFollowNextLinks:YES];
[docs setIsServiceRetryEnabled:YES];
[docs setUserCredentialsWithUsername:@"gmailaccount@gmail.com" password:@"password"];
}
return docs;
}
//@@@@@@@@@@@@@@
GDataServiceTicket *ticket;
#pragma mark docService
docsService = [self getdocservice];
NSURL *feedURL = [GDataServiceGoogleDocs docsFeedURL];
GDataQueryDocs *queryDocs = [GDataQueryDocs documentQueryWithFeedURL:feedURL];
[queryDocs setMaxResults:1000];
[queryDocs setShouldShowFolders:YES];
ticket = [docsService fetchFeedWithQuery:queryDocs delegate:self didFinishSelector:@selector(docsFetchTicket:finishedWithFeed:error:)];
// call back
-(void)docsFetchTicket:(GDataServiceTicket *)ticket finishedWithFeed:(GDataFeedDocList *)feed error:(NSError *)error
{
GDataFeedDocList *mDocListFeed = feed;
int numDocs = [[feed entries] count];
NSLog(@"NumDocs :%d\n Feed :%@",numDocs,mDocListFeed);
for (int i=0; i<numDocs; i++) {
GDataEntryDocBase *docEntry = [mDocListFeed entryAtIndex:i];
NSLog(@"\n@@@@@@@@@@@@ DocTitle :%@\n\n",[[docEntry content] sourceURL] );
}
}它正在显示我的帐户中的所有文档。但我不知道如何将这些文档下载到我的应用程序文档文件夹中。如果谁有想法,请帮助我。
发布于 2012-07-17 07:53:13
(免责声明:我不精通Objective-C)
GDataFeedDocList的每个条目都应该包含一个指向实际文件数据的链接。该链接包含在其"Content“属性中。在您的代码中,您似乎有一个URL (sourceURL),您需要使用一个经过身份验证的请求来下载内容。
您现在还应该使用较新的Drive,而不是使用较新的Objective-C客户端库的DocumentList API:
http://code.google.com/p/google-api-objectivec-client/
https://stackoverflow.com/questions/11135046
复制相似问题