Here is some code to get details from Twitter api. I'm new for Twitter integration in iOS applications. I'm new for this implementation.
-(void)TwitterAction {
TWTRSessionStore *store = [[Twitter sharedInstance] sessionStore];
NSString *userID = store.session.userID;
if (userID)
[store logOutUserID:userID];
[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error) {
if (session) {
[self usersShow:session.userID];
} else
NSLog(@"Error: %@", [error localizedDescription]);
}];
}
-(void)usersShow:(NSString *)userID {
//NSString *statusesShowEndpoint =[NSString stringWithFormat:@"https://api.twitter.com/1.1/favorites/create.json?id=%@",userID];
NSString *statusesShowEndpoint = @"https://api.twitter.com/1.1/users/show.json";
NSDictionary *params = @{@"user_id": userID};
NSError *clientError;
TWTRAPIClient *client = [TWTRAPIClient clientWithCurrentUser];
NSURLRequest *request = [client URLRequestWithMethod:@"GET" URL:statusesShowEndpoint parameters:params error:&clientError];
if (request)
{
[client sendTwitterRequest:request completion:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
if (data)
{
// handle the response data e.g.
NSError *jsonError;
NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];
userDict = @{@"name":[self dictonaryContainKey:json key:@"name"],@"imageUrl":[self dictonaryContainKey:json key:@"profile_image_url"],@"userName":[self dictonaryContainKey:json key:@"screen_name"],@"email":[self dictonaryContainKey:json key:@"gmail"],@"gender":[self dictonaryContainKey:json key:@"gender"]};
[self CreateAccountBySocialNetworks];
}
else
NSLog(@"Error code: %ld | Error description: %@", (long)[connectionError code], [connectionError localizedDescription]);
}];
}
else
NSLog(@"Error: %@", clientError);
}