Can we get email ID from Twitter oauth API?

PhpTwitterTwitter Oauth

Php Problem Overview


How to get email id of the user who accepted my Twitter application?

I have gone through lot of forums. But they have mentioned, it is not possible. Also those posts are older than a year. May I know whether it is possible to get the user email id through twitter API using PHP?

I am getting Twitter user details using the following URL:

https://api.twitter.com/1.1/account/verify_credentials.json

Php Solutions


Solution 1 - Php

This is now possible by filling out a form to request elevated permissions:

  1. Go to https://support.twitter.com/forms/platform
  2. Select "I need access to special permissions"
  3. Enter Application Name and ID. These can be obtained via https://apps.twitter.com/ -- the application ID is the numeric part in the browser's address bar after you click your app.
  4. Permissions Request: "Email address"
  5. Submit & wait for response
  6. After your request is granted, an addition permission setting is added in your twitter app's "Permission" section. Go to "Additional Permissions" and just tick the checkbox for "Request email addresses from users".

Note that user e-mail address has to be verified, otherwise Twitter refuses to provide it. (See include_email parameter description in elevated permissions doc page.)

Solution 2 - Php

Now you can fetch user email address from twitter API and it's a lot much easier. Just follow these steps...

  1. Goto Twitter Apps

  2. Click on 'Create New App'

  3. Fill all required credentials and click on 'Create your Twitter application'

  4. Now click on 'Permissions' tab -> check 'Request email addresses from users' field and click on 'Update Settings'. (check given picture)

  5. Now in your PHP code, set all app details and add this code!

    $params = array('include_email' => 'true', 'include_entities' => 'false', 'skip_status' => 'true');

    $data = $connection->get('account/verify_credentials', $params); // get the data

    // getting twitter user profile details $twt_id = $data->id; //twitter user id $twt_email = $data->email; //twitter user email

All Done. Hope it help you, good luck. ;)

enter image description here

Solution 3 - Php

It is now possible to retrieve a user's email address from Twitter (if the user permits it, of course).

You'll need to apply to have your application white-listed to receive xAuth.

Check here for more info: https://dev.twitter.com/rest/reference/get/account/verify_credentials

Solution 4 - Php

Yes you can get email address.This is now possible by filling out a some permission.

1.Go to this Link: https://apps.twitter.com/

2.After go to permission tab inside your created Application

3.Select Addition permission checkbox in your APP.

4.After successfully update setting you can get email address from Twitter.

If in some case you can not getting email address then please check your Oauth Api request url.

Your request url should be this type :https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true

Solution 5 - Php

It is not possible to get user's email address from twitter. You can see it here. You can open a form page on your callback page and get user's email address on that page. You can refer here for example usage

Solution 6 - Php

Here is how I have done this in ASP.Net using linqtoTwitter library http://www.bigbrainintelligence.com/Post/get-users-email-address-from-twitter-oauth-ap

// call verify credentials api
var twitterCtx = new TwitterContext(authTwitter);
var verifyResponse =
      await
          (from acct in twitterCtx.Account
           where (acct.Type == AccountType.VerifyCredentials) && (acct.IncludeEmail == true)
           select acct)
          .SingleOrDefaultAsync();

if (verifyResponse != null && verifyResponse.User != null)
{
    User twitterUser = verifyResponse.User;
    //assign email to existing authentication object
    loginInfo.Email = twitterUser.Email;

}

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVinoth BabuView Question on Stackoverflow
Solution 1 - PhpaleembView Answer on Stackoverflow
Solution 2 - PhpPranView Answer on Stackoverflow
Solution 3 - PhpKevin TraasView Answer on Stackoverflow
Solution 4 - PhpChirag PrajapatiView Answer on Stackoverflow
Solution 5 - PhpHüseyin BABALView Answer on Stackoverflow
Solution 6 - PhpdanielserafimovikView Answer on Stackoverflow