dtczp02204 2012-05-22 14:39
浏览 20
已采纳

Zend Gdata Calendar API返回“不支持3.0版”。

Receiving the following error when doing a simple calendar fetch:

Expected response code 200, got 403
Version 3.0 is not supported.

Code looks like:

Oauth

$options = array(
    'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER,
    'version' => '1.0',
    'signatureMethod' => 'HMAC-SHA1',
    'consumerKey' => $config['consumer_key'],
    'consumerSecret' => $config['consumer_secret']
);

/**
 * Create HTTP Client object which adds OAuth Authorization
 * headers to outbound requests.
 */
$this->_consumer = new Zend_Oauth_Consumer($options);
$this->_token = new Zend_Oauth_Token_Access();
$this->_http_client = $this->_token->getHttpClient($options);

Calendar Query

$calendarClient = new Zend_Gdata_Calendar(Oauth::I()->getHttpClient());
print $calendarClient->getMajorProtocolVersion();

$query = $calendarClient->newEventQuery();
$query->setUser('default');
$query->setVisibility('private');
$query->setProjection('full');

Oauth::I()->setRequestorId($query);
try {
  $list = $calendarClient->getCalendarEventEntry($query);
  var_dump($list);
} catch(Exception $e) {
  var_dump($e->getMessage());
}
var_dump($calendarEventsFeed);

When dumping $calenderClient under Zend_Http_Client_Adapter_Socket resource headers:

  ["gdata-version"]=>
  array(2) {
    [0]=>
    string(13) "GData-Version"
    [1]=>
    string(3) "3.0"
  }

however getMajorProtocolVersion() returns 1.

  • 写回答

1条回答 默认 最新

  • dongliyu3278 2012-05-23 06:46
    关注

    Solution is to setHeaders() on the HTTP Client whenever you need to change the GData Version. I am sure there is method specifically for this, but this works.

    // $http_client is Zend_Oauth_Token_Access()::getHttpClient()
    $http_client->setHeaders('GData-Version', '2.0');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题