在进行简单的日历获取时收到以下错误:
Expected response code 200, got 403
Version 3.0 is not supported.
代码如下:
认证
$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);
日历查询
$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);
在 Zend_Http_Client_Adapter_Socket 资源头下转储 $calenderClient 时:
["gdata-version"]=>
array(2) {
[0]=>
string(13) "GData-Version"
[1]=>
string(3) "3.0"
}
但是 getMajorProtocolVersion() 返回 1。