Thursday 16 November 2017

How Can we get email ID from Twitter oauth API? Solution

How to get email id of the user who accepted my Twitter application?
I have gone through a 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?
Answer:
Now you can fetch user email address from Twitter API and it's a lot much easier. Just follow these steps...
  1. Click on 'Create New App'
  2. Fill all required credentials and click on 'Create your Twitter application'
  3. Now click on 'Permissions' tab -> check 'Request email addresses from users' field and click on 'Update Settings'. (check given picture)
  4. 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 helps you, good luck.

No comments:

Post a Comment

cURL error 60: SSL certificate problem: unable to get local issuer certificate (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in Laravel

  WampServer: Download this file:  http://curl.haxx.se/ca/cacert.pem Place this file in the  C:\wamp64\bin\php\php7.1.9  folder Open  php.in...

Popular Articles