Can anybody help me with that?
I have posted a question on Stackoverflow.com:
I know that email is disabled, but the twitter add my application to the whitelist, so i think that now i can get the email of a user.
Thanks
If your app is whitelisted, there is information on this in the documentation for GET account/verify_credentials on the parameters to use.
1 Like
Hello,
I’ve followed the instructions, but still I dont have the email address.
Please help.
Can you share any example of the code you’re using? Have you regenerated your tokens? (please do not share your tokens on the forum).
Hi,
I have regenerated the key and secret twice and nothing.
My code, please check it:
require ("plugins/twitter/vendor/autoload.php");
use Abraham\TwitterOAuth\TwitterOAuth;
$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET);
$request_token = $connection->oauth("oauth/request_token", [ 'oauth_callback' => $CALLBACK_URL ]);
if($request_token['oauth_callback_confirmed'] == true){
$_SESSION['twitterLoginFlow']['token'] = $request_token['oauth_token'];
$_SESSION['twitterLoginFlow']['secret'] = $request_token['oauth_token_secret'];
$url = $connection->url("oauth/authorize", ["oauth_token" => $request_token['oauth_token']]);
$myOBJ->exitRedir($url);
}
CALLBACK_FILE:
session_start();
require ("my/config-file.php");
require ("my/class.myobj.php");
require ("plugins/twitter/vendor/autoload.php");
use Abraham\TwitterOAuth\TwitterOAuth;
$myOBJ = new myOBJ($pdo);
$myOBJ->Config = $Config;
$twitterData = $_SESSION['twitterLoginFlow'];
$oauth_token = isset($_GET['oauth_token'])?$_GET['oauth_token']:NULL;
$oauth_verifier = isset($_GET['oauth_verifier'])?$_GET['oauth_verifier']:NULL;
if($oauth_token != $twitterData['token']){
$_SESSION['invalidFlow'] = 1;
$myOBJ->exitRedir($EXIT_URL);
}
$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $twitterData['token'], $twitterData['secret']);
$accessData = $connection->oauth("oauth/access_token", ["oauth_verifier" => $oauth_verifier]);
$userConnection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $accessData['oauth_token'], $accessData['oauth_token_secret']);
$userData = $userConnection->get("account/verify_credentials", array('include_email' => 'true'));
/*
I already have tested so:
$userData = $userConnection->get("account/verify_credentials", array('include_email' => true));
and...
$userData = $userConnection->get("account/verify_credentials", array('include_email' => 1));
*/
$myOBJ->printArray($userData); exit;
Hello again,
The email is coming now.
I dont know the reason, because in first step, where we ask user’s permission, I dont see the phrase “Your email address”, but the result is comign with email address now.
…
[profile_use_background_image] =>
[has_extended_profile] => 1
[default_profile] =>
[default_profile_image] =>
[following] =>
[follow_request_sent] =>
[notifications] =>
[email] => user@emailaddress.com
Thanks for the help.