Php 使用google contacts api更改联系人时出现问题
我正试图通过PHP更改Google联系人,但对于每个请求,Google服务器都不会回答我。如果我试图以NULL形式发布google服务器,我会得到无效的XML,因此我认为PUT请求是正确的。 谁能帮我举几个例子吗? 这是PHP中的代码Php 使用google contacts api更改联系人时出现问题,php,google-contacts-api,php-curl,Php,Google Contacts Api,Php Curl,我正试图通过PHP更改Google联系人,但对于每个请求,Google服务器都不会回答我。如果我试图以NULL形式发布google服务器,我会得到无效的XML,因此我认为PUT请求是正确的。 谁能帮我举几个例子吗? 这是PHP中的代码 $access = 'xxx'; $user_email = urlencode('xxx@xxx'); $id_contatto = 'xxx'; $contactXML = ' <entry gd:etag="*"> <id
$access = 'xxx';
$user_email = urlencode('xxx@xxx');
$id_contatto = 'xxx';
$contactXML = '
<entry gd:etag="*">
<id>http://www.google.com/m8/feeds/contacts/'.$user_email.'/base/'.$id_contatto.'</id>
<updated>2019-05-27T17:07:02.303Z</updated>
<atom:category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact"/>
<gd:name>
<gd:givenName>Test</gd:givenName>
<gd:familyName>Test</gd:familyName>
<gd:fullName>Test Test</gd:fullName>
</gd:name>
<content type="text">Notes</content>
<link rel="http://schemas.google.com/contacts/2008/rel#photo" type="image/*" href="https://www.google.com/m8/feeds/photos/media/'.$user_email.'/'.$id_contatto.'"/>
<link rel="self" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/'.$user_email.'/full/'.$id_contatto.'"/>
<link rel="edit" type="application/atom+xml" href="https://www.google.com/m8/feeds/contacts/'.$user_email.'/full/'.$id_contatto.'"/>
<gd:phoneNumber rel="http://schemas.google.com/g/2005#other" primary="true">456-123-2133</gd:phoneNumber>
<gd:extendedProperty name="pet" value="hamster"/>
<gd:groupMembershipInfo deleted="false" href="http://www.google.com/m8/feeds/groups/'.$user_email.'/base/6"/>
</entry>
</pre>';
$headers = array(
'If-Match: *',
'Gdata-version: 3.0',
'Content-type: application/atom+xml',
);
$contactQuery = 'https://www.google.com/m8/feeds/contacts/default/full/'.$id_contatto.'?access_token='.$access;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $contactQuery );
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_PUT, true);
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);
if(curl_errno($ch)){
$result = curl_error($ch);
}
var_dump($result);
$access='xxx';
$user\u email=urlencode('xxx@xxx');
$id_contatto='xxx';
$contactXML='0
http://www.google.com/m8/feeds/contacts/“.$user\u email./base/”.$id\u contatto”
2019-05-27T17:07:02.303Z
试验
试验
测试
笔记
456-123-2133
';
$headers=数组(
'如果匹配:',
“Gdata版本:3.0”,
'内容类型:应用程序/atom+xml',
);
$contactQuery=https://www.google.com/m8/feeds/contacts/default/full/“.$id\u contatto.”?访问令牌=“.$access;
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$contactQuery);
curl_setopt($ch,CURLOPT_CUSTOMREQUEST,“PUT”);
curl_setopt($ch,CURLOPT_PUT,true);
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);
if(旋度误差($ch)){
$result=旋度误差($ch);
}
var_dump($结果);
这是超时后var_转储的结果:
字符串(0)“是否可以改用他们的API?不,我必须使用的API是不是这些可能使用他们的API?不,我必须使用的API是