Twitter API : Decode string returned by getFollowerIDsFor from Twitter (MGTwitterEngine for Obj-C)
New Question
Thank you for your reply Arcain. I guess question got mis-represented. I apologize for that.
My interpretation was like getFollowerIDsFor method as name suggests should be getting list of follower IDs, but it is not so.
My actual question is, how to use MGTwitterEngine API to get list of follower/following persons from Twitter. Though I went through documentation was not able to find out the same.
Regards,
Jennis
Previous Question
We can get list of Follower using getFollowerIDsFor through MGTwitterEngine object. It always returns some string which is not understandable for me i.e. how to decode or s开发者_高级运维omething like that ?
let say resultant string is "025815FA-BAF6-49E6-96B4-86F2D4C8C6CA"
how to understand what is there in this string ? can anyone highlight on this please ?
Help would be appreciated.
Regards, Jennis
That value is a unique identifier and doesn't really mean anything. I'm not familiar with Cocoa, but when I looked around I found the following in the README file for MGTwitterEngine, and it seems relevant to what you're asking:
A note about the data returned from Twitter
Each Twitter API method returns an NSString which is a unique identifier for that connection. Those identifiers are passed to all the delegate methods, so you can keep track of what's happening.
Whenever a request is successful, you will receive a call to your implementation of requestSucceeded: so you'll know that everything went OK. For most of the API methods, you will then receive a call to the appropriate method for the type of data you requested (statusesReceived:... or directMessagesReceived:... or userInfoReceived:...). The values sent to these methods are all NSArrays containing an NSDictionary for each status or user or direct message, with sub-dictionaries if necessary (for example, the timeline methods usually return statuses, each of which has a sub-dictionary giving information about the user who posted that status).
Just try calling some of the methods and use NSLog() to see what data you get back; you should find the format very easy to integrate into your applications.
Sometimes, of course, requests will fail - that's just how life is. In the unlikely event that the initial connection for a request can't be made, you will simply get nil back instead of a connection identifier, and then receive no further calls relating to that request. If you get nil back instead of an NSString, the connection has failed entirely. That's a good time to check that the computer is connected to the internet, and so on.
It's far more common however that the connection itself will go ahead just fine, but there will be an error on Twitter's side, either due to technical difficulties, or because there was something wrong with your request (e.g. you entered the wrong username and password, or you tried to get info on a user that doesn't exist, or some such thing). The specific error conditions are mostly documented in the Twitter API documentation online.
In these cases you'll receive a call to requestFailed:withError: which will include an NSError object detailing the error. Twitter usually returns meaningful HTTP error codes (like 404 for 'user not found', etc), and in that case the -domain of the NSError will be "HTTP" and the -code will be the relevant HTTP status code. The userInfo of the NSError will contain a key "body" that may contain the response body and "response" which will contain the NSHTTPURLResponse. This makes it really, really easy to know what's happening with your connections.
精彩评论