Skip to content

Commit

Permalink
Bug fixed on getUserContacts of Google.
Browse files Browse the repository at this point in the history
  • Loading branch information
pc committed Jan 31, 2017
1 parent 6b19a77 commit e716462
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions hybridauth/Hybrid/Providers/Google.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,24 +197,33 @@ function getUserProfile() {
*/
function getUserContacts() {
// refresh tokens if needed

$this->refreshToken();


$contacts = array();
if (!isset($this->config['contacts_param'])) {

$this->config['contacts_param'] = array("max-results" => 500);
}

// Google Gmail and Android contacts
if (strpos($this->scope, '/m8/feeds/') !== false) {

//https://www.google.com/m8/feeds/contacts/default/full?&alt=json&max-results='.$max_results.'&oauth_token='.$accesstoken;
$response = $this->api->api("https://www.google.com/m8/feeds/contacts/default/full?"
. http_build_query(array_merge(array('alt' => 'json', 'v' => '3.0'), $this->config['contacts_param'])));


$response = $this->api->api("https://www.google.com/m8/feeds/contacts/default/full?"
. http_build_query(array_merge(array('alt' => 'json'), $this->config['contacts_param'])));


if (!$response) {

return array();
}

if (isset($response->feed->entry)) {

foreach ($response->feed->entry as $idx => $entry) {
$uc = new Hybrid_User_Contact();
$uc->email = isset($entry->{'gd$email'}[0]->address) ? (string) $entry->{'gd$email'}[0]->address : '';
Expand Down Expand Up @@ -303,3 +312,4 @@ function addUrlParam($url, array $params) {
}

}

0 comments on commit e716462

Please sign in to comment.