我有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);
这是问题(在删除方法中):
我必须使用Google Etag handling,因为有多个人可以访问此联系人,因此我无法在Zend错误报告中使用this或建议here。有谁知道如何解决它?
非常感谢! Ajax的
编辑:这个bug根本没有修复,这里有人有这个问题吗?我很绝望.. :(答案 0 :(得分:0)
我有解决方案。
Zend \ Gdata \ App.php中有一个BUG
第547行(1.12.6版),在 $ headers [&#39; If-Match&#39;] =&#39; *&#39;; 中添加<如果条件。现在,您应该:
if ($method == 'DELETE') {
$rawData = null;
$headers['If-Match'] = '*';
}
让我保持联系;)