Zend GData - 无法删除谷歌联系人 - Etag 错误


Zend GData - can't delete google contact - Etag error

我对Zend框架有问题。我正在尝试从谷歌的服务器中删除单个联系人。 我有课:

class GContacts
{
    const BASE_FEED_URI = 'https://www.google.com/m8/feeds';
    private $client = NULL;
    private $gData = NULL;
    private $contScope = '';
    private $groupScope = '';
    public function __construct($userName,$pass){       
        ini_set('include_path', LIB_DIR);
        require_once(''Zend'Loader.php');
        Zend_Loader::loadClass('Zend_Gdata');
        Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
        Zend_Loader::loadClass('Zend_Http_Client');
        Zend_Loader::loadClass('Zend_Gdata_Query');
        Zend_Loader::loadClass('Zend_Gdata_Feed');          
        $this -> client = Zend_Gdata_ClientLogin::getHttpClient($userName, $pass, 'cp');
        $this -> gData = new Zend_Gdata($this -> client);
        $this -> gData -> setMajorProtocolVersion(3);
        $this -> contScope = self :: BASE_FEED_URI . '/contacts/' . urlencode($userName);
    }
    public function addContact($cont){
        $doc = new DOMDocument();
        $doc -> formatOutput = true;
        // header
        $entry = $doc -> createElement('atom:entry');
        $entry -> setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:atom', 'http://www.w3.org/2005/Atom');
        $entry -> setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:gd', 'http://schemas.google.com/g/2005');
        $entry -> setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:gContact', 'http://schemas.google.com/contact/2008');
        $doc -> appendChild($entry);
        // add name element
        $name = $doc -> createElement('gd:name');
        $entry -> appendChild($name);
        $fullName = $doc -> createElement('gd:fullName', 'John Doe');
        $name -> appendChild($fullName);
        // insert entry
        $addResult = $this -> gData -> insertEntry($doc -> saveXML(), 'http://www.google.com/m8/feeds/contacts/default/full');
        return $this -> parseUniqueId($addResult -> id);
    }
    public function delete($gid){
        // Should be some work with Etag, but Zend is buggy and it doesn't work
        $entry = $this -> gData -> getEntry($this -> contScope . '/full/' . $gid);
        $entry -> delete();
    }
    private function parseUniqueId($link){
        $arr = explode('/',$link);
        return end($arr);
    }
}

并打电话:

$gCont = new GContacts($userName,$pass);
$gid = $gCont -> addContact('param will be soon');
$gCont -> delete($gid);

这是问题(在删除方法中):

  • 预期响应代码 200,需要 403 If-Match 或 If-None-Match 标头或条目 etag 属性

我必须使用谷歌Etag处理,因为有不止一个人可以访问此联系人,所以我不能在Zend bugreport中使用这个或建议。有谁知道如何解决它?

多谢!阿贾克斯

编辑:此错误根本没有修复,这里有人有这个问题吗?我很绝望..:(

我有解决方案。

Zend''Gdata''App 中存在一个错误.php

第 547 行(在版本 1.12.6 上),在 if 条件中添加行 $headers['If-Match'] = '*';。现在,您应该有:

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

;)与我保持联系