How to get the Twitter user's email using Hybridauth?
Asked Answered
I

4

7

Can any body help how to get the Twitter email I am using this link in php codeigniter here i am getting my information except email. Then how to fetch the email? is there any scope shall we specified in config file?

Inquiry answered 29/12, 2012 at 8:29 Comment(0)
O
8

You can't.

Twitter API does not provide access to a user's email address


Here's a response to this same question from a Twitter employee

The API won't return an email address to you. If you're interested in a user's email address, you'll have to ask the user for it within your own application as a completely distinct act.

Oliverolivera answered 29/12, 2012 at 8:31 Comment(2)
You are wrong. Twitter does allow. Check my anwser https://mcmap.net/q/1441339/-how-to-get-the-twitter-user-39-s-email-using-hybridauthShutout
This answer is wrong now in 2017 as per above comment. It shouldn't be the accepted answer anymore.Iranian
S
5

I'm a just a few years late to answer this question but I'm going to answer it anyway.

You can!!!

Check the link where this issue has been addressed and answered.

  • Basically, you first need get elevated permissions from the twitter developer account by providing your privacy policy url and the terms of conditions url.

  • Apply this step after getting email access permission from twitter dev support.

    /public_html/application/config/hybridauthlib.php

And add : "includeEmail" => true to the Twitter provider.

"Twitter" => array (
"enabled" => true,
"keys" => array ( "key" => "Your_Twitter_App_Key", "secret" => "Your_Twitter_Secret_Key" ),
"includeEmail" => true,
)
Shutout answered 30/1, 2017 at 19:25 Comment(1)
Also you have to request additional permission for user email address. link apps.twitter.com/app in permissions sectionAgustin
M
1

It should be possible now. First, whitelist your app.

https://support.twitter.com/forms/platform70 [I have added a youtube link for DEMO LINK and my app url in github for APPLICATION URL] and clicked on "submit" button.

Next,You will get 1st email from twitter(If you dont get an email from twitter,re-fill the form and send again) saying "Thanks for reaching out".Then after a few hours you get a 2nd email saying that url app is whitelisted.

Once they say that your App is whitelisted, update your App's settings in Twitter Developer portal. Sign in to apps.twitter.com and:

On the 'Settings' tab, add a terms of service and privacy policy URL on the 'Permissions' tab, change your token's scope to request email. This option will only been seen, once your App gets whitelisted.

Next,you may have to regenerate your access token in https://apps.twitter.com .And also use https://api.twitter.com/1.1/account/verify_credentials.json?include_email=true in order to get the user's email address

Marchal answered 15/11, 2015 at 23:41 Comment(0)
L
-1

I was using CodeIgniter version of HybridAuth library, and in this file

app/application/third_party/hybridauth/Hybrid/Providers/Twitter.php

Modifed this line

$response = $this->api->get( 'account/verify_credentials.json' );

to the below one

$response = $this->api->get( 'account/verify_credentials.json',['include_entities' => 'true', 'skip_status' => 'true', 'include_email' => 'true'] );

also, added the below line before returning of user profile

$this->user->profile->email      = (property_exists($response,'email'))?$response->email:"";

and started receiving the email id

Lamella answered 22/3, 2017 at 8:0 Comment(1)
Instead of altering base files of the library I would probably have created my own modified provider implementation inheriting from Twitter and making the needed modification. Makes it easier when you apply updates to Hybridauth further down the road.Torquemada

© 2022 - 2024 — McMap. All rights reserved.