“需要If-Match或If-None-Match标头或条目etag属性"尝试使用Zend Framework更新Google联系人上的联系人时出错 [英] "If-Match or If-None-Match header or entry etag attribute required" Error when trying to update a contact on google contacts using Zend Framework
问题描述
我正在尝试使用zend框架更新我的google联系人,但出现以下错误:
Hi guys I'm trying to update my google contacts using the zend framework but I'm getting the following error:
Expected response code 200, got 403 If-Match or If-None-Match header or entry etag attribute required
以下是我的代码:
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Gdata_Query');
Zend_Loader::loadClass('Zend_Gdata_Feed');
$client = getGoogleClient('cp'); // this is a function I made - its working fine
$client->setHeaders('If-Match: *');
$gdata = new Zend_Gdata($client);
$gdata->setMajorProtocolVersion(3);
$query = new Zend_Gdata_Query($id);// id is the google reference
$entry = $gdata->getEntry($query);
$xml = simplexml_load_string($entry->getXML());
$xml->name->fullName = trim($contact->first_name).' '.trim($contact->last_name);
$entryResult = $gdata->updateEntry($xml->saveXML(), $id);
怎么回事?
推荐答案
我在 http://www.ibm.com/developerworks/forums/thread.jspa?messageID=14476692
这是该链接中的消息:
//清单6中的/// updateEntry调用添加: $ extra_header = array(); $ extra_header ='*';
// in listing 6... // somewhere before the updateEntry call add: $extra_header = array(); $extra_header='*';
//,然后替换当前 使用以下命令调用updateEntry: $ entryResult = $ gdata-> updateEntry($ xml-> saveXML(),$ entry-> getEditLink()-> href,null,$ extra_header);
// and then replace the current updateEntry call with the following: $entryResult = $gdata->updateEntry($xml->saveXML(),$entry->getEditLink()->href,null,$extra_header);
对Google联系人的更新现在可以使用.
Updates to Google Contacts now work.
我将其用于我的代码.同样,帖子中的代码也有问题. 那是
i get it work for my code. again there is a problem with the code in the post as well. that is
$extra_header = array();
$extra_header = array('If-Match'=>'*');
$entryResult = $contactObj->updateEntry($xml->saveXML(),$entry->getEditLink()->href,null,$extra_header);
我认为它也可以帮助您解决更新问题.
I think it will help you solve the update problem as well.
谢谢
这篇关于“需要If-Match或If-None-Match标头或条目etag属性"尝试使用Zend Framework更新Google联系人上的联系人时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!