Not receiving email address from verify_credentials (PHP/twitteroauth)

web
php
email

#1

I recently had my application whitelisted for the email privilege for twitter OAuth.

Now I’m trying to pass the include_email(true) parameter to GET account/verify_credentials but I’m still not receiving an email address. I’ve revoked access with the account I was testing with, but after re-authenticating, I’m still not seeing an email address in the user payload. Also, my test account has verified its email address.

In the permission dialogue on the twitter side of the authorization handshake, it does show “email address” as part of the requested permissions. Also, I am able to successfully pass other parameters (and see the expected behaviour) like include_entities(false) and include_user_entities(false).

I reached out to twitter support but all they were able to do is verify our permissions:

We can confirm that your app ID XXXX has all required permissions to request user emails.

$twitterClient = new TwitterOAuth($app_key, $app_secret, $user_token, $user_secret); $twitterClient->get('account/verify_credentials', ["include_email" => true]);


#2

Use ["include_email" => "true"] instead.


#3

This solved it. Thank you!!

On a side note :expressionless:, why does it need to be the string “true” as opposed to just the boolean true?


#4

The API requires string "true"|"false" while PHP coerces boolean true to string "0". I’ve got a task to implement a fix within TwitterOAuth itself.


#5

Makes sense, thanks for the explanation.


#6