Verify_credentials.json and user e-mail


#1

When I make request to verify_credentials.json - I got array with user data. Then I put on checkbox in permissions part “Request email addresses from users” But when I add to request parameter include_email=true I got 401 Authorization Required. Thanks for any help


#2

Are you able to share a code sample?

After modifying permissions for the app, you’ll need to reauthenticate the user in order to inherit the new permissions.


#3

Yes, I testing always for new users with twitter authorization page and button. It is my code after token successfull request:

define ('URL_ACCOUNT_DATA', 'https://api.twitter.com/1.1/account/verify_credentials.json');
$oauth_nonce = md5(uniqid(rand(), true));
$oauth_timestamp = time();

$oauth_token = $result['oauth_token'];
$oauth_token_secret = $result['oauth_token_secret'];
$screen_name = $result['screen_name'];

$oauth_base_text = "GET&";
$oauth_base_text .= urlencode(URL_ACCOUNT_DATA).'&';
$oauth_base_text .= urlencode('oauth_consumer_key='.TWITTER_CONSUMER_KEY.'&');
$oauth_base_text .= urlencode('oauth_nonce='.$oauth_nonce.'&');
$oauth_base_text .= urlencode('oauth_signature_method=HMAC-SHA1&');
$oauth_base_text .= urlencode('oauth_timestamp='.$oauth_timestamp."&");
$oauth_base_text .= urlencode('oauth_token='.$oauth_token."&");
$oauth_base_text .= urlencode('oauth_version=1.0&');
$oauth_base_text .= urlencode('screen_name='.$screen_name);
$oauth_base_text .= urlencode('&include_email=true');

$key = TWITTER_CONSUMER_SECRET . '&' . $oauth_token_secret;
$signature = base64_encode(hash_hmac("sha1", $oauth_base_text, $key, true));

$url = URL_ACCOUNT_DATA;
$url .= '?oauth_consumer_key=' . TWITTER_CONSUMER_KEY;
$url .= '&oauth_nonce=' . $oauth_nonce;
$url .= '&oauth_signature=' . urlencode($signature);
$url .= '&oauth_signature_method=HMAC-SHA1';
$url .= '&oauth_timestamp=' . $oauth_timestamp;
$url .= '&oauth_token=' . urlencode($oauth_token);
$url .= '&oauth_version=1.0';
$url .= '&screen_name=' . $screen_name;
$url .= '&include_entities=true';

$response = file_get_contents($url);

#4

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.