Skip to content

Commit

Permalink
Merge pull request hybridauth#519 from guarly/master
Browse files Browse the repository at this point in the history
[Twitter] Add email option to Twitter API
  • Loading branch information
StorytellerCZ committed Aug 26, 2015
2 parents 4e0d993 + b3da1fe commit 5dc0a5a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion hybridauth/Hybrid/Providers/Twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ function loginFinish() {
* {@inheritdoc}
*/
function getUserProfile() {
$response = $this->api->get('account/verify_credentials.json');
$includeEmail = isset($this->config['includeEmail']) ? (bool) $this->config['includeEmail'] : false;
$response = $this->api->get('account/verify_credentials.json'. ($includeEmail ? '?include_email=true' : ''));

// check the last HTTP status code returned
if ($this->api->http_code != 200) {
Expand All @@ -129,6 +130,7 @@ function getUserProfile() {
$this->user->profile->profileURL = (property_exists($response, 'screen_name')) ? ("http://twitter.com/" . $response->screen_name) : "";
$this->user->profile->webSiteURL = (property_exists($response, 'url')) ? $response->url : "";
$this->user->profile->region = (property_exists($response, 'location')) ? $response->location : "";
if($includeEmail) $this->user->profile->email = (property_exists($response, 'email')) ? $response->email : "";

return $this->user->profile;
}
Expand Down
3 changes: 2 additions & 1 deletion hybridauth/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
),
"Twitter" => array(
"enabled" => true,
"keys" => array("key" => "", "secret" => "")
"keys" => array("key" => "", "secret" => ""),
"includeEmail" => false
),
// windows live
"Live" => array(
Expand Down

0 comments on commit 5dc0a5a

Please sign in to comment.