Question

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.

Was it helpful?

Solution

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');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top