[英]How to get google contact information using api in php
How to get google contact using google-api-php-client in php . 如何使用php中的google-api-php-client获取google联系人。
i have try below code for this but not able to get contacts. 我已经尝试下面的代码,但无法获得联系。 is there any one who has idea about this .
有谁对此有想法吗?
$clientId = 'xxxxxxxxx';
$clientSecret = 'xxxxxx';
$redirectUrl = base_url().'login';
// Google Client Configuration
$gClient = new Google_Client();
$gClient->setApplicationName('Login to atx.com');
$gClient->setClientId($clientId);
$gClient->setClientSecret($clientSecret);
$gClient->setRedirectUri(base_url().'login');
//$gClient->addScope('profile');
//$gClient->addScope('https://www.google.com/m8/feeds');
$google_oauthV2 = new Google_Oauth2Service($gClient);
if (isset($_GET['code'])) {
$gClient->authenticate();
$this->session->set_userdata('token', $gClient->getAccessToken());
//redirect($redirectUrl);
}
$token = $this->session->userdata('token');
$token = json_decode($token,true);
$access_token = $token['access_token'];
echo "<pre>";print_r($token['access_token']);
$url = 'https://www.google.com/m8/feeds/contacts/default/full?alt=json&v=3.0&oauth_token='.$token['access_token'];
// $response = file_get_contents($url);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
curl_close($ch);
$response = json_decode($response, true);
I got the solution follow Below link steps u will get all the contact after login. 我得到的解决方案如下链接步骤,您将在登录后获得所有联系人。
https://www.design19.org/blog/import-google-contacts-php/ https://www.design19.org/blog/import-google-contacts-php/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.