【问题标题】:How Delete / update / Create Google Contacts API in PHP如何在 PHP 中删除/更新/创建 Google 联系人 API
【发布时间】:2016-09-05 22:08:42
【问题描述】:

我正在尝试使用 Google 联系人 API,我可以检索联系人,但我不明白如何使用 API 进行删除、创建或删除。我尝试了一个简单的表单,但出现错误 401

<?php
  }else{
    $client->setAccessToken($_SESSION['token']);
    $token = json_decode($_SESSION['token']);
    var_dump($token->access_token);
    var_dump($client->getAccessToken());
    $curl = curl_init('https://www.google.com/m8/feeds/contacts/default/full?alt=json&max-results=50&access_token='.$token->access_token);
    curl_setopt($curl , CURLOPT_RETURNTRANSFER , true);
    curl_setopt($curl , CURLOPT_SSL_VERIFYPEER , false);
    curl_setopt($curl , CURLOPT_TIMEOUT , 10);
    $contact_json = curl_exec($curl);
    var_dump($contact_json);
    curl_close($curl) ;
    $contacts = json_decode($contact_json , true);
    var_dump( $contacts['feed']['entry'][7]);
    $monContact = $contacts['feed']['entry'][7];
    $monContactId =  $monContact['id']['$t'];



  }
 ?>
 <form class="" action="<?= $monContactId?>" method="DELETE">
   <input type="submit" name="name" value="DELETE">
 </form>

我就这样尝试过,但我不知道如何操作。

感谢您的帮助。

【问题讨论】:

标签: php google-api google-api-php-client


【解决方案1】:

有一个强大的类,你可以使用它: https://github.com/rapidwebltd/php-google-contacts-v3-api

您可以像这样检索所有联系人:

rapidweb\googlecontacts\factories\ContactFactory::getAll()

或创建联系人:

$name = "Frodo Baggins";
$phoneNumber = "06439111222";
$emailAddress = "frodo@example.com";

$newContact = rapidweb\googlecontacts\factories\ContactFactory::create($name, $phoneNumber, $emailAddress);

有关更多信息,请查看此博客文章:http://www.rapidweb.biz/news/php-library-for-the-google-contacts-api-v3-06102593/

【讨论】:

猜你喜欢
  • 2016-11-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-18
相关资源
最近更新 更多