Hi,

Yes, those two should be enough for contacts. Rremember to activate 2-
legged OAuth in the Control Panel:
http://code.google.com/apis/accounts/docs/OAuth.html#GoogleAppsOAuth

Here is a full example:

#!/usr/bin/perl -w

use strict;
use Getopt::Long;
use HTTP::Request::Common "GET";
use LWP::UserAgent;
use Digest::MD5  qw(md5 md5_hex md5_base64);
use Net::OAuth;
require 5.6.0;

my $lwp_object = LWP::UserAgent->new;

my $user_email = "[email protected]";
my $consumer_key = "domain.com";
my $consumer_secret = "gy...";
my $url = "http://www.google.com/m8/feeds/contacts/$user_email/full";;
my $time = time;
my $nonce = md5_hex("nonce_key".$time);

my $request = Net::OAuth->request('consumer')->new(
                       consumer_key => $consumer_key,
                       consumer_secret => $consumer_secret,
                       request_url => $url,
                       signature_method => 'HMAC-SHA1',
                       request_method => 'GET',
                       timestamp => $time,
                       nonce => $nonce,
                       extra_params =>  {
                               xoauth_requestor_id => $user_email,
                               'max-results' => 10,
                       },
                      );
$request->sign;
my $lwp_request = GET $request->to_url;
my $response = $lwp_object->request($lwp_request);
print $response->content;

-Julian

On Apr 6, 5:36 pm, holm basedow <[email protected]> wrote:
> Hello Julian,
>
> thank you for your answer,
>
> i sent this request, but i get error "Unknown authorization header". is
> there enough to send cosumer_key and consumer_secret,
> what is with token and token_secret?
>
> my $req = Net::OAuth->request('consumer')->new(
>             consumer_key => 'xxx',
>             consumer_secret => 'xxx',
>             request_url => 
> 'http://www.google.com/m8/feeds/contacts/default/full',
>             signature_method => 'HMAC-SHA1',
>             request_method => 'GET',
>             timestamp => time,
>             nonce => join('', rand_chars(size=>16, set=>'alphanumeric')),
>             extra_params =>  {
>                   xoauth_requestor_id => $user_email,
>                   'max-results' => 1,
>             },
> );
>
> mike
>
> 2009/4/6 Julian (Google) <[email protected]>
>
>
>
>
>
> > Hi,
>
> > I think you should add extra_params with the xoauth and the max-
> > results information, for example:
>
> > my $request = Net::OAuth->request('consumer')->new(
> >                       consumer_key => $consumer_key,
> >                       consumer_secret => $consumer_secret,
> >                       request_url => $url,
> >                       signature_method => 'HMAC-SHA1',
> >                       request_method => 'GET',
> >                       timestamp => $time,
> >                       nonce => $nonce,
> >                       extra_params =>  {
> >                               xoauth_requestor_id => $user_email,
> >                               'max-results' => 1,
> >                       },
> >                      );
>
> > -Julian
>
> > On Apr 5, 12:00 pm, mike <[email protected]> wrote:
> > > Hello,
>
> > > i make a request like this:
>
> > > #!/usr/bin/perl -w
>
> > > use strict;
> > > use Net::OAuth;
> > > use HTTP::Request::Common;
> > > use LWP::UserAgent;
> > > use Data::Dumper;
> > > my $ua = LWP::UserAgent->new;
> > > #use Test::More tests => 12;
> > > use Data::Random qw(rand_chars);
>
> > > my $req = Net::OAuth->request("protected resource")->new(
> > >             consumer_key => 'xxx',
> > >             consumer_secret => 'xxx',
> > >             request_method => 'GET',
> > >             signature_method => 'HMAC-SHA1',
> > >             timestamp => time,
> > >             nonce => join('', rand_chars(size=>16,
> > > set=>'alphanumeric')),
> > >             request_url => 'http://www.google.com/m8/feeds/contacts/
> > > default/full',
> > >             token => 'xxx',
> > >             token_secret => 'xxx',
> > >           );
>
> > > $req -> sign();
> > > my $res = $ua->request(GET($req->request_url,
> > >            Authorization => $req->to_authorization_header));
>
> > > if (!$res->is_success) {
> > >    die 'Could not get feed: ' . $res->status_line . ' ' . $res->content;
> > > }else{
>
> > >    print $res->status_line;
>
> > > }
>
> > > but when i try a url with a param like this
>
> > > request_url => 'http://www.google.com/m8/feeds/contacts/default/full?
> > > max-result=5'
>
> > > i get this error "Unknown authorization header"
>
> > > any ideas?
>
> > > best requards
>
> --
> mfg Holm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Contacts API" 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-contacts-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to