执行简单的日历提取时收到以下错误:
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。
解决方案是在需要更改GData版本时在HTTP客户端上设置Headers((。我确信有专门针对此的方法,但这有效。
// $http_client is Zend_Oauth_Token_Access()::getHttpClient()
$http_client->setHeaders('GData-Version', '2.0');