Domanda

Sono in grado di ottenere token autorizzati e anche ottenere risultati da make_restricted_request ma non posso interpretare i risultati.Sono tutti simili- 13T01: 26: 56.834ZHTTP: //www.google.com/m8/feeds/Contacts/UserEmail/Base/12010-01-

Tuttavia sembra che siano risultati effettivi che ci sono esattamente tanti risultati del valore "Risultati del massimo" che fornisco nella richiesta di seguito.


.
package Net::AppThatUsesOAuth;

use strict;
use base qw(Net::OAuth::Simple);

sub new {
    my $class  = shift;
    my %tokens = @_;

    return $class->SUPER::new( tokens => \%tokens,
                               protocol_version => '1.0a',
                               urls   => {
                                    request_token_url => "https://www.google.com/accounts/OAuthGetRequestToken?scope=https://www.google.com/m8/feeds/",
                                    authorization_url => "https://www.google.com/accounts/OAuthAuthorizeToken",
                                    access_token_url  => "https://www.google.com/accounts/OAuthGetAccessToken",
                               });
}


sub view_restricted_resource {
    my $self = shift;
    my $url= 'https://www.google.com/m8/feeds/contacts/default/full' ;
    return $self->make_restricted_request($url, 'GET', 'max-results' => 100 );
}

package main;
use CGI;
use Data::Dumper;

my $cgi = new CGI;
print $cgi->header(-charset => 'utf-8');

my $app     = Net::AppThatUsesOAuth->new(%tokens);
if ($app->authorized) {
   my $response = $app->view_restricted_resource;
   print "Restricted resource = ".(Dumper $response)."\n";
}
exit;
.
.

output è (100 righe) come:

$ var1= Blessisso ({'_protocol'=> 'http / 1.1', '_content'=> 'UserEmail2014-02-27T02: 15: 52.254ZuserNameEusereMailContacts10361100HTTP: //www.google.com/m8/Feeds/Contacts/UserMail/base/02012-04-13t01:26:56.834zhttp://www.google.com/m8/feeds/Contacts/UserEmail/base/12010-01-21t19:32:41.739zhttp://www.google..com / m8 / feed / contatti / usermail / base / 22008-04-09t08: 47: 53.076zhttp://www.google.com/m8/feeds/Contacts/UserEmail/base/32010-01-21T19: 32:41.739ZHTTP: //www.google.com/m8/feeds/Contacts/UREMAIL/BASE/42008-04- ...

È stato utile?

Soluzione

Il $response restituito da make_restricted_request è un HTTP::Response Object.Net::OAuth::Simple Già controlla se la richiesta ha esito positivo, in modo da poter accedere al contenuto della risposta utilizzando $response->content o $response->decoded_content.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top