“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

查看:13
本文介绍了“If-Match 或 If-None-Match 标头或条目 etag 属性需要"尝试使用 Zend Framework 更新 google 联系人上的联系人时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在尝试使用 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

这是来自该链接的消息:

here is the message from that link:

//在清单 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆