我正在尝试谷歌联系人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>
我已经试过了,但是我不知道怎么操作这个东西。
谢谢你的帮助。
有一个强大的类,你可以使用它:https://github.com/rapidwebltd/php-google-contacts-v3-api
您可以像这样检索所有联系人:
rapidwebgooglecontactsfactoriesContactFactory::getAll()
或创建联系人:
$name = "Frodo Baggins";
$phoneNumber = "06439111222";
$emailAddress = "frodo@example.com";
$newContact = rapidwebgooglecontactsfactoriesContactFactory::create($name, $phoneNumber, $emailAddress);
更多信息请查看此博客文章:http://www.rapidweb.biz/news/php-library-for-the-google-contacts-api-v3-06102593/