如何使用PHP删除单个Gmail联系人
我正在使用此脚本尝试从GMAIL中删除联系人,但无法删除 我是指: 我的脚本:如何使用PHP删除单个Gmail联系人,php,google-contacts-api,Php,Google Contacts Api,我正在使用此脚本尝试从GMAIL中删除联系人,但无法删除 我是指: 我的脚本: $id = '******'; $contact_mail = '********'; $contact_id = '************'; $contactXML = '<?xml version="1.0" encoding="utf-8"?> <entry gd:etag="*"> <id>http://www.google.com/m8/feeds/contact
$id = '******';
$contact_mail = '********';
$contact_id = '************';
$contactXML = '<?xml version="1.0" encoding="utf-8"?>
<entry gd:etag="*">
<id>http://www.google.com/m8/feeds/contacts/'.$contact_mail.'/base/'.$contact_id.'</id>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact"/>
<link rel="self" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/'.$contact_mail.'/full/'.$contact_id.'"/>
<link rel="edit" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/'.$contact_mail.'/full/'.$contact_id.'"/></entry>';
$headers = array(
'Host: www.google.com',
'Gdata-version: 3.0',
'Content-length: '.strlen($contactXML),
'Content-type: application/atom+xml',
'Authorization: OAuth '.$access_token
);
$contactQuery = 'https://www.google.com/m8/feeds/contacts/default/full/'.$contact_id.'';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $contactQuery );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $contactXML);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
$result = curl_exec($ch);
print_r($result);
$id='*****';
$contact_mail='********';
$contact_id='************';
$contactXML='0
http://www.google.com/m8/feeds/contacts/“.$contact\u mail./base/”.$contact\u id
';
$headers=数组(
“主持人:www.google.com”,
“Gdata版本:3.0”,
“内容长度:”.strlen($contactXML),
'内容类型:应用程序/atom+xml',
“授权:OAuth”。$access\u令牌
);
$contactQuery=https://www.google.com/m8/feeds/contacts/default/full/“.$contact_id.”;
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$contactQuery);
curl_setopt($ch,CURLOPT_CUSTOMREQUEST,“DELETE”);
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$contactXML);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
curl_setopt($ch,CURLOPT_超时,10);
curl_setopt($ch,CURLOPT_FAILONERROR,true);
$result=curl\u exec($ch);
打印(结果);
请找出我的错误或指导我任何其他解决方案
授权:OAuth…
更改为授权:承载人…