Zend / Google应用程序 - 删除条目 - if-match og etag属性需要

时间:2012-08-08 11:47:44

标签: php zend-framework google-apps

尝试删除条目时会返回错误吗?

你不应该只是调用delete方法删除条目!?

$this->client = Zend_Gdata_ClientLogin::getHttpClient($this->admin_user, $this->admin_pass, 'cp');
$this->client->setHeaders('If-Match: *');
$this->gdata = new Zend_Gdata($this->client);
$this->gdata->setMajorProtocolVersion(3);

$feed = $gdata->getFeed($query);
foreach($feed as $entry){
    $entry->delete();
}

错误:

ERROR: Expected response code 200, got 403
If-Match or If-None-Match header or entry etag attribute required

1 个答案:

答案 0 :(得分:2)

编辑你的文件App.php和第538行(我的情况至少),在函数prepareRequest()内部改变这个:

if ($method == 'DELETE') {
    $rawData = null;
}

到此

if ($method == 'DELETE') {
    $rawData = null;
    $headers['If-Match'] = '*';
}