小编All*_*tas的帖子

Google API Contacts v.3,PHP:向群组添加联系人

我成功地设法与cURL创建了一个新的联系人,但是当我想为这个联系人添加组成员身份时,我得到400错误.我已阅读此文档 并提出相同的请求,但它无效.我究竟做错了什么?谢谢你的任何想法!

这就是我用组信息创建XML的方法:

$doc = new DOMDocument('1.0', 'UTF-8');
$doc->formatOutput = true;

$entry = $doc->createElement('entry');
$entry->setAttribute('gd:etag', $etag);
$doc->appendChild($entry);

$category = $doc->createElement('category');
$category->setAttribute('scheme', 'http://schemas.google.com/g/2005#kind');
$category->setAttribute('term', 'http://schemas.google.com/contact/2008#contact');
$entry->appendChild($category);

$id = $doc->createElement('id', 'http://www.google.com/m8/feeds/contacts/default/base/'.$idgmail);
$entry->appendChild($id);

$updated = $doc->createElement('updated', $update_info);
$entry->appendChild($updated);

// Add group info (My Contacts)

$group = $doc->createElement('gContact:groupMembershipInfo');
$entry->appendChild($group);
$group->setAttribute('deleted', 'false');
$group->setAttribute('href', 'http://www.google.com/m8/feeds/groups/default/base/6');

// Add another group info

$group = $doc->createElement('gContact:groupMembershipInfo');
$entry->appendChild($group);
$group->setAttribute('deleted', 'false');
$group->setAttribute('href', 'http://www.google.com/m8/feeds/groups/default/base/'.$my_group_id);

$group_info = $doc->saveXML();
Run Code Online (Sandbox Code Playgroud)

这是我的cURL:

$url = 'https://www.google.com/m8/feeds/contacts/default/full/'.$idgmail.'/';

$headers = array(
'Host: www.google.com',
'Gdata-version: 3.0',
'Content-length: '.strlen($group_info),
'Content-type: …
Run Code Online (Sandbox Code Playgroud)

php xml curl google-contacts-api

4
推荐指数
1
解决办法
3277
查看次数

标签 统计

curl ×1

google-contacts-api ×1

php ×1

xml ×1