Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在google contacts api v3中将联系人添加到组中_Php_Google Contacts Api_Group Membership - Fatal编程技术网

Php 如何在google contacts api v3中将联系人添加到组中

Php 如何在google contacts api v3中将联系人添加到组中,php,google-contacts-api,group-membership,Php,Google Contacts Api,Group Membership,我正在尝试将联系人添加到google contacts中的组中。当我在谷歌的“OAuth 2.0游乐场”中尝试它时,它是有效的,但从我的web应用程序中,使用完全相同的标题、发布方法和正文,我得到了“错误400:错误请求” 这是我的代码(php): $contact=” 杰克·弗罗斯特 温特公司。 (206)555-1213 '; $url='1https://www.google.com/m8/feeds/contacts/MY_EMAIL@gmail.com/full/; $method

我正在尝试将联系人添加到google contacts中的组中。当我在谷歌的“OAuth 2.0游乐场”中尝试它时,它是有效的,但从我的web应用程序中,使用完全相同的标题、发布方法和正文,我得到了“错误400:错误请求”

这是我的代码(php):

$contact=”
杰克·弗罗斯特
温特公司。
(206)555-1213  
';
$url='1https://www.google.com/m8/feeds/contacts/MY_EMAIL@gmail.com/full/;
$method='POST';
$headers=[“Host”=>“www.google.com”,“Gdata version”=>“3.0”,“Content length”=>strlen($contact),“Content type”=>“application/atom+xml”];
$result=$googleService->request($url、$method、$contact、$headers);
当我省略groupMembershipInfo位时,它就起作用了


Joachim发现了它:别忘了在xml中添加xmlns:gContact=“schemas.google.com/contact/2008”,所以它看起来像:

<?xml version="1.0"?> 
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:gd="http://schemas.google.com/g/2005" 
xmlns:gContact="http://schemas.google.com/contact/2008"> 

<gd:name> ...

...

这似乎对我不起作用。我想它必须使用
gContact:groupMembershipInfo
元素?在这里你可以找到解决方案:或者在这里:谷歌联系人可以看到下面我的新答案
<?xml version="1.0"?> 
<atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:gd="http://schemas.google.com/g/2005" 
xmlns:gContact="http://schemas.google.com/contact/2008"> 

<gd:name> ...