我正在尝试以编程方式(使用gdata api)从youtube帐户检索传入的邮件。
我的要求:
NSURL *url = [NSURL URLWithString:@"http://gdata.youtube.com/feeds/api/users/my_nick/inbox"];
NSMutableURLRequest *inboxRequest = [NSMutableURLRequest requestWithURL:url];
NSString *authStr = [NSString stringWithFormat:@"GoogleLogin auth=%@", authMarker];
[inboxRequest setValue:authStr forHTTPHeaderField:@"Authorization"];
[inboxRequest addValue:@"Content-Type" forHTTPHeaderField:@"application/x-www-form-urlencoded"];
[inboxRequest setHTTPMethod:@"GET"];
NSHTTPURLResponse *response = NULL;
NSData *responseData = [NSURLConnection sendSynchronousRequest:inboxRequest returningResponse:&response error:nil];
NSString *responseDataString = [[NSString alloc] initWithData:responseData encoding:NSASCIIStringEncoding];
NSLog(@"\n%@\n", responseDataString);
NSLog(@"\n%@\n", [inboxRequest ]);
返回没有条目的Feed ...(虽然我可以在网站上看到收到的消息)
来自nslog的回复:
<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>http://gdata.youtube.com/feeds/api/users/thisistestnick/inbox</id><updated>2011-06-16T14:45:00.475Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#videoMessage'/><title type='text'>Inbox of thisistestnick</title><logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo><link rel='alternate' type='text/html' href='http://www.youtube.com/my_messages?folder=inbox&filter=videos'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/thisistestnick/inbox'/><link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/thisistestnick/inbox/batch'/><link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/users/thisistestnick/inbox?start-index=1&max-results=25'/><author><name>thisistestnick</name><uri>http://gdata.youtube.com/feeds/api/users/thisistestnick</uri></author><generator version='2.0' uri='http://gdata.youtube.com/'>YouTube data API</generator><openSearch:totalResults>0</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage></feed>
有什么不对?请帮助。
答案 0 :(得分:0)
为什么你不能使用 gdata-objectivec lib api而不是自己解析?我没有尝试检索“收件箱”,但在获取我想要的信息方面相当成功。使用它的好处是:
a)您以原生格式(字符串和词典)获取信息,lib负责为您解析订阅源。
b)主要是,不会有任何解析/ api理解错误(我想这是你的问题的原因)。