I wrote the following code:
NSURL *url = [NSURL URLWithString:@\"http://api.twitter.com/1.1/users/show.json\"];
NSDictionary *params = [NSDictionary diction
It's profile_image_url_https ;)
We can access profile image without using Twitter sdk .Using Social framework in iOS we can get using it.
I use ACAccounts instead of Twitter IOS SDK's like MGTwitterEngine etc.......
The twitter account provided in the IPhone Settings will be used.
if(!accountStore)
accountStore = [[ACAccountStore alloc] init];
ACAccountType *accountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
[accountStore
requestAccessToAccountsWithType:accountType
options:NULL
completion:^(BOOL granted, NSError *error) {
if (granted) {
// Step 2: Create a request
NSArray *accountsArray = [accountStore accountsWithAccountType:accountType];
self.twitterAccount = [accountsArray objectAtIndex:0];
// NSString *userID = [[twitterAccount valueForKey:@"properties"] valueForKey:@"user_id"];
NSURL *url = [NSURL URLWithString:@"https://api.twitter.com/1.1/users/show.json"];
NSDictionary *params = @{@"screen_name" : twitterAccount.username
};
SLRequest *request =
[SLRequest requestForServiceType:SLServiceTypeTwitter
requestMethod:SLRequestMethodGET
URL:url
parameters:params];
// Attach an account to the request
[request setAccount:[accountsArray lastObject]];
// Step 3: Execute the request
[request performRequestWithHandler:^(NSData *responseData,
NSHTTPURLResponse *urlResponse,
NSError *error) {
if (responseData) {
if (urlResponse.statusCode >= 200 && urlResponse.statusCode < 300) {
[self performSelectorOnMainThread:@selector(twitterdetails:)
withObject:responseData waitUntilDone:YES];
}
else {
NSLog(@"The response status code is %d", urlResponse.statusCode);
}
}
}];
}
else
{
dispatch_async(dispatch_get_main_queue(), ^{
[self dismissError:@"Please set up your twitter account in iphone settings"];
});
}
}];
-(void)twitterdetails:(NSData *)responseData {
NSError* error = nil;
NSDictionary* json = [NSJSONSerialization
JSONObjectWithData:responseData //1
options:NSJSONReadingAllowFragments
error:&error];
NSString *name = [json objectForKey:@"name"];
NSString *scrnm = [json objectForKey:@"screen_name"];
NSString *twitterid = [json objectForKey:@"id"];
NSString *prof_img = [json objectForKey:@"profile_image_url"];
NSString *location = [json objectForKey:@"location"];
}