49

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

  • Here i will get a solution also for the problem mentioned by vendors. (i.e) how to handle the situation for that case.. – Vinoth Babu Mar 25 '14 at 6:49
  • I can't find it in the Twitter docs! Only found answers from the Twitter community forums: twittercommunity.com/t/… – jonprasetyo Oct 5 '14 at 16:02
  • 2
    @PaulDessert a member of this particular vendor's staff has stated on a public forum that they have implemented functionality without documenting it. It stands to reason then, that someone (like the developers of the functionality, for instance) know how to use the feature despite it not appearing in the API documentation at all. These same people might be able to offer someone like Vinoth help he couldn't find elsewhere. – jeteon Apr 9 '15 at 20:02
  • As of January 7, 2017 this repo I created works and shows you exactly how to extract the users email address. github.com/DZuz14/CompleteSignInWithTwitterPHP – Dan Zuzevich Jan 7 '17 at 16:59
94

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.)

  • 1
    I never knew this existed before now, many thanks! – Terry Kernan Nov 5 '15 at 0:22
  • 1
    Do they actually grant this permission easily? Or is it just reserved for already successful apps? – anges244 Feb 26 '16 at 13:13
  • 1
    @anges244 It seems they do grant it easily, at least to a developer who has never had a complaint. My app isn't even accessible online yet, so they can't have looked at it. – tremby Feb 29 '16 at 21:39
  • 2
    @aleemb, once you have the permission, how do you get the email address? I authorized my test user with this extra permission, but still don't see the email address anywhere in the users/show response. Is there something which needs to be added to the request? – tremby Feb 29 '16 at 21:40
  • 2
    FYI, I found my answer on Twitter Developer Forums (twittercommunity.com/t/…). In the PHP source I had specified the parameter list as array('include_email'=>true), which becomes include_email=1 in the url. I changed the source to array('include_email'=>'true'), and it started working. What a wonky API! The value of the preceding boolean parameter to this url, skip_status, is documented "When set to either true, t or 1 statuses will not...". But include_email says "When set to true email will be returned". – sootsnoot Jun 24 '16 at 15:45
0

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

31

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

  • 2
    After looking for almost 2 hours, this was the solution. This should be heavily upvoted. It is January 1/7/2017 as of my typing this. None of the other ways of structuring the url worked anywhere I found on the internet. – Dan Zuzevich Jan 7 '17 at 15:22
  • 4
    After doing the same. still not getting email address. – Dhirender Jan 10 '17 at 6:27
  • 1
    Same, not getting email.. – muaaz Apr 1 '17 at 11:04
  • Working. Thanks – RajivRisi Apr 5 '17 at 13:28
  • not working for me either. any other ways? can i request for email address in development phase? – shrawan_lakhe Sep 4 '17 at 11:00
1

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;

}
  • What was the credentialstore that you used? I tried their code sample but only get back "my" user account info - not the user info of the user that just logged in. – Tim Wheeler Sep 15 '17 at 3:27
6

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

  • 1
    You should have mentioned "xAuth is not available for web-based applications". This is why your answer doesn't apply to the op's problem. – TNT Aug 30 '15 at 18:44
4

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

protected by Community Jan 7 '17 at 17:58

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.