Hi Lluis,

There's a decent PHP library on oauth.net that should
help with the HMAC_SHA1 signing:
http://oauth.googlecode.com/svn/code/php/

Here's what I was able to get working with that library:

<?php
require_once("OAuth.php");

$consumer_key = 'yourdomain.com';
$consumer_secret = 'YOUR_CONSUMER_SECRET';
$hmac_sig_method = new OAuthSignatureMethod_HMAC_SHA1();
$contacts_feed = 'http://www.google.com/m8/feeds/contacts/default/
full/';
$user = '[EMAIL PROTECTED]';
$url = $contacts_feed. '?xoauth_requestor_id=' . $user;

$consumer = new OAuthConsumer($consumer_key, $consumer_secret, NULL);
$req = OAuthRequest::from_consumer_and_token($consumer, NULL, 'GET',
$contacts_feed, array('xoauth_requestor_id' => $user));
$req->sign_request($hmac_sig_method, $consumer, NULL);

echo signedGET($url, $req->to_header());

function signedGET($url, $auth_header) {
  $curl = curl_init($url);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/atom+xml',
    $auth_header
  ));
  $response = curl_exec($curl);

  if (!$response) {
    die('Error: ' . curl_error($curl) . "\n");
  }
  curl_close($curl);

  return $response;
}
?>

The important thing to note is that you do NOT
fetch a token with 2 legged OAuth.  Just query
the feed directly by appending the xoauth_requestor_id
parameter with the user's email:
GET http://www.google.com/m8/feeds/contacts/default/full/[EMAIL PROTECTED]

Eric

On Nov 11, 2:33 pm, Lluis <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've read the 
> articlehttp://www.google.com/support/a/bin/answer.py?hl=en&answer=61017
> talking about Oauth two-legged authentication process.
>
> We have a global addressbook, that every user has the responsibility
> to synchronize with its own Gmail contacts personal database.
>
> Instead of that, we're interested with the possibility to synchro
> contacts without involving the user. At nightly basis for example
>
> I'm a PHP programmer. I would very grateful if someone could pointing
> me directions and/or provide some PHP code examples or experience
>
> Thanks in advance, Lluís
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Apps 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://groups.google.com/group/google-apps-apis?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to