HI everyone! I followed the tutorial here: 
http://code.google.com/apis/gdata/docs/auth/oauth.html#OAuthRequestToken

and I built the following code: 

<? 
session_start(); 
ini_set("display_errors", 1); 
require_once 'Zend/Loader.php'; 
require_once 'Zend/Oauth/Consumer.php'; 
$CONSUMER_KEY = '1212121.apps.googleusercontent.com'; 
$CONSUMER_SECRET = 'gVdWZAMrxi121212QSz9Zj'; 
$BASE_URL = 'http://www.xxx.com/helloworld';
$STORE_PATH = "/tmp/_php_consumer_test"; 
Zend_Loader::loadClass('Zend_Gdata'); 
Zend_Loader::loadClass('Zend_Gdata_Gapps'); 
Zend_Loader::loadClass('Zend_Gdata_Query'); 
$SCOPES = array( 
  'https://www.google.com/m8/feeds/'
); 
$options = array( 
    'requestScheme' => Zend_Oauth::REQUEST_SCHEME_HEADER, 
    'version' => '1.0', 
    'signatureMethod' => 'HMAC-SHA1', 
    'consumerKey' => $CONSUMER_KEY, 
    'consumerSecret' => $CONSUMER_SECRET, 
        'callbackUrl' => 'http://www.stingerit.com/helloworld/test.php', 
        'requestTokenUrl' => '
https://www.google.com/accounts/OAuthGetRequestToken', 
        'userAuthorizationUrl' => '
https://www.google.com/accounts/OAuthAuthorizeToken', 
  'accessTokenUrl' => 'https://www.google.com/accounts/OAuthGetAccessToken'  
      
        
); 
$consumer = new Zend_Oauth_Consumer($options); 
if (!isset($_SESSION['ACCESS_TOKEN'])) { 
         $_SESSION['REQUEST_TOKEN'] = 
serialize($consumer->getRequestToken(array('scope' => implode(' ', 
$SCOPES)))); 
} 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 

$approvalUrl = $consumer->getRedirectUrl(array('hd' => 'default')); 
echo "<a href=\"$approvalUrl\">Grant access"; 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 

        if (!isset($_SESSION['ACCESS_TOKEN'])) { 
          if (!empty($_GET) && isset($_SESSION['REQUEST_TOKEN'])) { 
                $_SESSION['ACCESS_TOKEN'] = 
serialize($consumer->getAccessToken($_GET, 
unserialize($_SESSION['REQUEST_TOKEN']))); 
          } 
        } 
        if (isset($_SESSION['ACCESS_TOKEN'])) { 
          $accessToken = unserialize($_SESSION['ACCESS_TOKEN']); 
        } else { 
          exit; 
        } 
$httpClient = $accessToken->getHttpClient($options); 
$client = new Zend_Gdata($httpClient); 
$query = new Zend_Gdata_Query("
http://www.google.com/m8/feeds/contacts/default/full";); 
$feed = $client->getFeed($query); 
foreach ($feed->entries as $entry) { 
  echo "$entry->title\n"; 
} 
?> 



However, it throws an error saying: 

Grant access 
Fatal error: Uncaught exception 'Zend_Oauth_Exception' with message 
'Authorized token from Service Provider does not match supplied Request 
Token details' in 
/home/stingeri/public_html/helloworld/Zend/Oauth/Consumer.php:208 Stack 
trace: #0 /home/stingeri/public_html/helloworld/test.php(38): 
Zend_Oauth_Consumer->getAccessToken(Array, Object(Zend_Oauth_Token_Request)) 
#1 {main} thrown in 
/home/stingeri/public_html/helloworld/Zend/Oauth/Consumer.php on line 208 

So it looks like I'm providing wrong tokens. Can you please tell me what I 
do wrong? 

Regards 
M. 

-- 
You received this message because you are subscribed to the Google
Groups "Google Contacts, Shared Contacts and User Profiles APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/contacts/community/forum.html

Reply via email to