我尝试了几种不同的方法来使用 AFNetworking 从 Google 文档中提取内容。
- 我修改了可接受的内容类型。
- 使用过 AFKiss 功能
- 使用常规 AFHttp 操作
仍然无法从下面的代码中获取任何内容。如果有人有一些想法,应该可以重现。
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"https://spreadsheets.google.com/feeds/worksheets/0AhNgJb3GRiT3dEFkYmJVQ1pUUXBpdWlOYjFBMUtpOEE/private/full"]];
AFXMLRequestOperation *operation = [AFXMLRequestOperation XMLParserRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, NSXMLParser *XMLParser) {
NSLog(@"Finished");
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, NSXMLParser *XMLParse) {
NSLog(@"Failed");
}];
[operation start];
最佳答案
在浏览器中查看该链接,无需登录 Google 帐户。它没有任何内容,因此无论您如何尝试都无法加载 xml。
您需要在您的应用中添加 Google 身份验证才能查看看起来的电子表格。信息可以在 Authenticating Users in Mobile Apps 找到指南。
关于ios - AFXMLRequestOperation 与 Google 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15855443/