semifor / Net-Twitter

A Perl interface to the Twitter APIs
83 stars 37 forks source link

include_email for api 1.1 #64

Closed Karldevine closed 7 years ago

Karldevine commented 8 years ago

ref: https://dev.twitter.com/rest/reference/get/account/verify_credentials there is an include_email flag that can be set for verify_credentials now.

just needs adding to RESTv1_1.pm

twitter_api_method verify_credentials => ( description => <<'', Returns an HTTP 200 OK response code and a representation of the requesting user if authentication was successful; returns a 401 status code and an error message if not. Use this method to test if supplied user credentials are valid.

path     => 'account/verify_credentials',
method   => 'GET',
params   => [qw/include_entities skip_status include_email/],
booleans => [qw/include_entities skip_status include_email/],
required => [qw//],
returns  => 'ExtendedUser',

);

semifor commented 8 years ago

Something's fishy, here. It doesn't work as advertised for me. Seems like a huge privacy violation if Twitter is actually sharing email addresses with 3rd party apps. I've requested some clarification from the Twitter API team.

In the meantime, you can use this (or any other new or undocumented option). Net::Twitter passes all provided options through to Twitter. So, this should work.

my $r = $nt->verify_credentials({ include_email => 1 })

Karldevine commented 8 years ago

The code does not return an email unless i've made the changes above. Looks like the param isn't passed. The email setting has to be applied for with twitter - it is listed on the permissions approval screen to the user

semifor commented 8 years ago

Yeah. Just discovered this is a case of RTFM. The option is definitely getting passed. I've verified that. Perhaps Twitter is being pedantic about the value. Give this a try:

$r = $nt->verify_credentials({ include_email => 'true' });

Twitter usually accepts 'true', 't', or 1 for boolean options. Perhaps not with this option. Adding the option to booleans as you've done above results in Net::Twitter translating perl truthy values to 'true' and falsey values to 'false'.