【发布时间】:2018-05-25 15:24:39
【问题描述】:
- 我正在使用 Google API PHP Client Library v2.1.3
- 我正在关注Domain Shared Contacts 的文档
- 我正在关注批量processing guidelines进行删除
这是我使用的逻辑:
$xmlBuild = "<feed xmlns='http://www.w3.org/2005/Atom'
xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
xmlns:batch='http://schemas.google.com/gdata/batch'
xmlns:gd='http://schemas.google.com/g/2005'
xmlns:gContact='http://schemas.google.com/contact/2008'>";
$xmlBuild .= "<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'>";
$xmlBuild .= "<batch:id>1</batch:id><batch:operation type='delete'/>";
$xmlBuild .= "<id>http://www.google.com/m8/feeds/contacts/my.domain/base/1b93ef80b806243</id>";
$xmlBuild .= "<link rel='edit' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/my.domain/full/1b93ef80b806243/1812952240373020'/>";
$xmlBuild .= "</entry>";
$xmlBuild .= "</feed>";
$len = strlen($xmlBuild);
$options = array(
"headers" => array(
"Content-type" => "application/atom+xml; charset=UTF-8;",
"Content-lenght" => $len
),
"body" => $xmlBuild
);
$httpClient = $client->authorize();
$request = $httpClient->delete("https://www.google.com/m8/feeds/contacts/my.domain/full/batch", $options);
$response = $request->getBody()->getContents();
print_r($response); //This prints "Contact ID not found."
// ??? why ???
我很确定我所做的一切都是正确的。对我来说,这似乎是一种错误的行为。我已经搜索了任何显示如何执行此操作的示例,但均无济于事。这里有没有人能够确定我的逻辑是否有问题?提前感谢您提供的任何帮助。
P.D.插入方法就像一个魅力。问题仅在于删除联系人。我还没有测试更新方法,但它都指出几乎与删除相同。不分批做删除是没有问题的。
【问题讨论】:
-
如果您尝试其他批处理方法,例如添加或更新,它是否也不起作用?
-
@noogui 当我进行批处理插入时,添加工作正常。删除是它不起作用的那个。我已经发送了带有和不带有
<link rel='edit' type='application/atom+xml' href='https://www.google.com/m8/feeds/contacts/my.domain/full/1b93ef80b806243/1812952240373020'/>的请求,但它仍然无法正常工作。不幸的是,文档中没有关于如何批量删除的示例。
标签: php google-api google-api-php-client google-admin-sdk