Bhumesh Purohit
Bhumesh Purohit

Reputation: 499

Get User Name and profile picture in twitter

I have implemented Twitter Login using fabric. but not getting profile Picture and much more information like email address, etc. I have implemented Following Code for that

[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession *session, NSError *error)
{
    [objAppData hideLoader];

    if (session)
    {
        [objAppData hideLoader];
        NSLog(@"signed in as %@", [session userName]);
    }
    else
    {
        [objAppData hideLoader];
        NSLog(@"error: %@", [error localizedDescription]);
    }
}];

I have getting only username and User Id. from above code. so, I have implemented another code for that

TWTRAPIClient *client = [TWTRAPIClient clientWithCurrentUser];
NSURLRequest *request = [client URLRequestWithMethod:@"GET"
                                                 URL:@"https://api.twitter.com/1.1/account/verify_credentials.json"
                                          parameters:@{@"include_email": @"true", @"skip_status": @"true"}
                                               error:nil];
[client sendTwitterRequest:request completion:^(NSURLResponse *response, NSData *data, NSError *connectionError) {


    NSLog(@"%@",data);
     NSLog(@"%@",response);
     NSLog(@"%@",connectionError);




}];

but still getting null value for data and responce and get forbidden (403) in connectionError.

Upvotes: 0

Views: 272

Answers (1)

Mike Bonnell
Mike Bonnell

Reputation: 16239

Mike from Fabric here.

A 403 means you don't have the permissions to get this information. Requesting email address permissions needs to be specifically requested as your key needs additional permission for this. As mentioned in the documentation, "Requesting a user’s email address requires your application to be whitelisted by Twitter. To request access, please visit https://support.twitter.com/forms/platform."

Upvotes: 1

Related Questions