Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get twitter profile pic using api 1.1 from iOS?
    primarykey
    data
    text
    <p>I am using MGTwitterEngine lib to authenticate Twitter account, but after successful login I want to get user profile pic but not able to get it and following method is stopped working:</p> <p><a href="https://api.twitter.com/1.1/users/profile_image?screen_name=username&amp;size=bigger" rel="nofollow">https://api.twitter.com/1.1/users/profile_image?screen_name=username&amp;size=bigger</a></p> <p>I just tried above method but no success. Then I have did lot of research on it and I finally got following api to get user profile information which include profile pic:</p> <p><a href="https://api.twitter.com/1.1/users/show.json?screen_name=username" rel="nofollow">https://api.twitter.com/1.1/users/show.json?screen_name=username</a></p> <p>But this api requires authentication by passing Authorization in Request header which I was not able to generate.</p> <p>Here is my code which I have tried:</p> <p>here authdata is the string which I am getting back from MGTwitterEngine lib after successful login.</p> <pre><code>NSString *authData = [[NSUserDefaults standardUserDefaults] valueForKey:@"authData"]; NSString *subAuthdata = [authData substringFromIndex:[authData rangeOfString:@"oauth_token_secret="].location]; subAuthdata = [subAuthdata substringToIndex:[subAuthdata rangeOfString:@"&amp;user_id="].location]; NSLog(@"%@", subAuthdata); NSLog(@"encoded: %@", [self base64Encode:subAuthdata]); NSString *accessTokenHeaderToPost = [NSString stringWithFormat:@"Basic %@", [self base64Encode:subAuthdata]]; NSString *twitURL = @"https://api.twitter.com/1.1/users/show.json?screen_name=username"; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; [request setURL:[NSURL URLWithString: twitURL]]; [request setHTTPMethod:@"GET"]; [request setValue:accessTokenHeaderToPost forHTTPHeaderField:@"Authorization"]; NSError *err; NSURLResponse *response; NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&amp;response error:&amp;err]; NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; NSLog (@"RESP: %@", responseString); </code></pre> <p>But it always says Bad authentication data.</p> <p>Please help me on this...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload