【问题标题】:How to get google contact information using api in php如何在php中使用api获取google联系信息
【发布时间】:2017-11-09 10:35:45
【问题描述】:

如何在 php 中使用 google-api-php-client 获取 google 联系人。

我为此尝试了以下代码,但无法获取联系人。有没有人对此有想法。

    $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);

【问题讨论】:

    标签: php api google-api


    【解决方案1】:

    我得到了解决方案,请按照以下链接步骤登录后您将获得所有联系方式。

    https://www.design19.org/blog/import-google-contacts-php/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-15
      • 1970-01-01
      • 1970-01-01
      • 2023-03-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-31
      相关资源
      最近更新 更多