I have already gotten permission from twitter to request e-mails and enabled it in my app.
I'm using Abraham's OAuth.
My problem is that I don't know the parameter for accessing a users e-mail, and I can't find it in twitter's documentation.
Here's the code where I would grab it:
$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
$params =array();
$params['include_entities']='false';
$content = $connection->get('account/verify_credentials',$params);
if($content && isset($content->screen_name) && isset($content->name))
{
$_SESSION['name']=$content->name;
$_SESSION['image']=$content->profile_image_url;
$_SESSION['twitter_id']=$content->screen_name;
//redirect to main page.
I would assume now that in $content is some parameter for the users e-mail address that they consented for me to take. I've tried "email", "email_address", "e-mail", and "e-mail_address" but those were all undefined.
I would like to know what the parameter is to access a user's e-mail.
Turns out this is what that $params array is for. Who knew?
$connection = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
$params =array();
$params['include_entities']='false';
$params['include_email']='true';//Added this line
$content = $connection->get('account/verify_credentials', $params);
if($content && isset($content->screen_name) && isset($content->name))
{
$_SESSION['name']=$content->name;
$_SESSION['image']=$content->profile_image_url;
$_SESSION['twitter_id']=$content->id;
$_SESSION['email']=$content->email;//The parameter is 'email'
//redirect to main page.