2011-06-16 79 views
2

我试图以编程方式(使用gdata api)从YouTube帐户检索传入邮件。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 ]); 

回输......(虽然我可以在网站上看到传入消息)

从这里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&amp;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&amp;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

我的问题太简单了还是v.v.? – gozie 2011-06-20 07:05:52

回答

0

为什么你不能使用, gdata-objectivec lib api的做法,而不是你自己的解析?我没有尝试检索'收件箱',但获得我想要的信息相当成功。使用它的优点是:

a)您以原生格式(字符串和字典)获取信息,lib为您解析提要。
b)主要是,不会有任何解析/ API理解错误(我认为这是你的问题的原因)。