Skip to content

Commit

Permalink
Updated to use mapProfile() for non-guaranteed data.
Browse files Browse the repository at this point in the history
  • Loading branch information
uzyn committed Oct 6, 2012
1 parent 7ebe6d1 commit cd98c49
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions TwitterStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,20 +108,15 @@ public function oauth_callback() {
if ($results !== false && !empty($results['oauth_token']) && !empty($results['oauth_token_secret'])) {
$credentials = $this->_verify_credentials($results['oauth_token'], $results['oauth_token_secret']);

if (!empty($credentials['id'])){
if (!empty($credentials['id'])) {

$this->auth = array(
'provider' => 'Twitter',
'uid' => $credentials['id'],
'info' => array(
'name' => $credentials['name'],
'nickname' => $credentials['screen_name'],
'location' => $credentials['location'],
'description' => $credentials['description'],
'image' => $credentials['profile_image_url'],
'urls' => array(
'twitter' => str_replace('{screen_name}', $credentials['screen_name'], $this->strategy['twitter_profile_url']),
'website' => $credentials['url']
'twitter' => str_replace('{screen_name}', $credentials['screen_name'], $this->strategy['twitter_profile_url'])
)
),
'credentials' => array(
Expand All @@ -131,12 +126,16 @@ public function oauth_callback() {
'raw' => $credentials
);

$this->mapProfile($credentials, 'location', 'info.location');
$this->mapProfile($credentials, 'description', 'info.description');
$this->mapProfile($credentials, 'profile_image_url', 'info.image');
$this->mapProfile($credentials, 'url', 'info.urls.website');

$this->callback();
}
}
} else {
$error = array(
'provider' => 'Twitter',
'code' => 'access_denied',
'message' => 'User denied access.',
'raw' => $_GET
Expand Down Expand Up @@ -195,7 +194,6 @@ private function _request($method, $url, $params = array(), $useauth = true, $mu
return $response;
} else {
$error = array(
'provider' => 'Twitter',
'code' => $code,
'raw' => $this->tmhOAuth->response['response']
);
Expand Down

0 comments on commit cd98c49

Please sign in to comment.