Zend Framework

GData Ignores my parameters (max-results, start-index etc) when fetching feeds

Details

  • Type: Sub-task Sub-task
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.5.0
  • Fix Version/s: 1.10.1
  • Component/s: Zend_Gdata
  • Labels:
    None

Description

GData Ignores my parameters (max-results, start-index etc) when fetching feeds.
No matter what parameter values I add, the GData cbntacts feed always returns the same data set (first 25 entries)

Here's my code:

<?php
session_start();
//header("Content-type: text/xml");

require_once 'Zend/Oauth/Consumer.php';
require_once 'Zend/Crypt/Rsa/Key/Private.php';
require_once 'Zend/Gdata/ClientLogin.php';
require_once 'Zend/Gdata.php';

$users_index = $_SESSION['users_index'];

// my rsa key string. when in production, put this string in an
external file and call it using get_file_contents
$test_cert = <<<_CERT
----BEGIN RSA PRIVATE KEY----
sadfdsfsdfdsfsdfsdfsdsdfsdfsdfsdfsdfsd
----END RSA PRIVATE KEY----
_CERT;

$options = array(
'requestScheme' => Zend_Oauth::REQUEST_SCHEME_QUERYSTRING,
'version' => '1.0',
'signatureMethod' => 'RSA-SHA1',
'callbackUrl' => 'http://www.mydomain.com/act/test', // UPDATE FOR
YOUR DETAILS
'requestTokenUrl' => 'https://www.google.com/accounts/
OAuthGetRequestToken',
'userAuthorisationUrl' => 'https://www.google.com/accounts/
OAuthAuthorizeToken',
'accessTokenUrl' => 'https://www.google.com/accounts/
OAuthGetAccessToken',
'consumerKey' => 'www.mydomain.com', // UPDATE FOR YOUR DETAILS
'consumerSecret' => new Zend_Crypt_Rsa_Key_Private($test_cert)
);

/**

  • Example utilises the Google Contacts API
    */

$consumer = new Zend_Oauth_Consumer($options);

if (!isset($_SESSION['ACCESS_TOKEN_GOOGLE'])) {
if (!empty($_GET)) { // Google does not like empty POST bodies - switch to GET $token = $consumer->getAccessToken($_GET, unserialize($_SESSION['REQUEST_TOKEN_GOOGLE']), Zend_Oauth::GET); $_SESSION['ACCESS_TOKEN_GOOGLE'] = serialize($token); } else { // Default POST works fine here since POST body contains scope parameter $token = $consumer->getRequestToken(array('scope'=>'http:// www.google.com/m8/feeds'), Zend_Oauth::GET); $_SESSION['REQUEST_TOKEN_GOOGLE'] = serialize($token); $consumer->redirect(); exit; }
} else { $token = unserialize($_SESSION['ACCESS_TOKEN_GOOGLE']); $_SESSION['ACCESS_TOKEN_GOOGLE'] = null; }

// OAuth Access Token Retreived; Proceed to query Data API
$client = $token->getHttpClient($options);
//$client->setUri('http://www.google.com/m8/feeds/groups/default/
full');
//$client->setMethod(Zend_Http_Client::GET);

$contact = new Zend_Gdata($client);

$contact_count =0;

$query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/
default/full');

$feed = $contact->getFeed($query);

$name = "";
$email = "";

$db = new db_connect();
$db = $db->db;

foreach($feed as $entry){
$name = $entry->title;

$parts = $entry->getExtensionElements();
foreach($parts as $p){
$element = $p->getDOM();
switch($element->tagName){ case 'email': $email = $element->getAttribute('address'); break; default: continue; }
}
$data = array(
'name' => "$name",
'email' => "$email",
'users_index' => $users_index
);

//insert into DB here

$contact_count++;
}

Activity

Hide
Trevor Johns added a comment -

This is being caused by Zend_Oauth_client not preserving query parameters on a GET request.

Attached ZF-4158_v1.patch as a patch to fix this behavior, to be sent to Pádraic Brady for review.

Show
Trevor Johns added a comment - This is being caused by Zend_Oauth_client not preserving query parameters on a GET request. Attached ZF-4158_v1.patch as a patch to fix this behavior, to be sent to Pádraic Brady for review.
Hide
Jon Cockle added a comment -

I am still seeing this issue with the latest version in the incubator:
http://framework.zend.com/svn/framework/standard/incubator/library/Zend/

and the above patch unfortunately doesn't seem to fix it.

I'm experiencing the same issue - GET params are stripped before sending requests, meaning that using Zend_Oauth for GData doesn't work beyond authentication.

Is there any update on this?

Show
Jon Cockle added a comment - I am still seeing this issue with the latest version in the incubator: http://framework.zend.com/svn/framework/standard/incubator/library/Zend/ and the above patch unfortunately doesn't seem to fix it. I'm experiencing the same issue - GET params are stripped before sending requests, meaning that using Zend_Oauth for GData doesn't work beyond authentication. Is there any update on this?
Hide
Jon Cockle added a comment -

sorry, my mistake.

the patch fixes the issue but you still need to manually set:

$client->setRequestScheme(Zend_Oauth::REQUEST_SCHEME_QUERYSTRING);

before sending your request.

looks good though.

Show
Jon Cockle added a comment - sorry, my mistake. the patch fixes the issue but you still need to manually set: $client->setRequestScheme(Zend_Oauth::REQUEST_SCHEME_QUERYSTRING); before sending your request. looks good though.
Hide
Pádraic Brady added a comment -

Fixed in r20938

Show
Pádraic Brady added a comment - Fixed in r20938

People

Vote (0)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: