Twitter API “retweeted_status” field in “home_time

2020-07-30 02:50发布

问题:

I'm using MGTwitterEngine + OAuth in my iPhone application. All works fine, but when I'm requesting home_timeline of friends_timeline with include_rt option I'm not getting retweeted_status field.

dev.twitter.com/doc/get/statuses/home_timeline Responce should contain "retweeted_status" structure for retweets (as you can see in the sample). It describes source tweet that was retweeted.

dev.twitter.com/console If you will use Twitter Console - you will get this structure successfully.

But my app recieves this structure as empty. Like " < retweeted_status>\n< /retweeted_status>". All requests are working great except this.

Have anyone seen this? What's the solution?

PS: I've find this http://www.mail-archive.com/twitter-development-talk@googlegroups.com/msg25383.html and a few similar discussions, but this is madness if it is true. )

Thanks.

回答1:

I've found the answer. It was so simple. SAOAuthTwitterEngine engine uses MGTwitterEngine but allows it to use OAuth. But this engine is using MGTwitterEngine created in 2008, when MGTwitterEngine didn't know about "retweeted_status" because this feature appeared later.

Anyway. All I was need to do - if to add [elementName isEqualToString:@"retweeted_status"] case for

  • (void)parser:(NSXMLParser *)theParser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict

and

  • (void)parser:(NSXMLParser *)theParser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName

methods in MGTwitterStatusesParser.m similarly to [elementName isEqualToString:@"status"] case.