我可以获得授权令牌,甚至可以从make_restricted_request获取结果,但我无法解释结果。他们都喜欢 - 13T01:26:56.834Zhttp://www.google.com/m8/feeds/contacts/userEMAIL/base/12010-01-
然而,似乎它们是实际结果,其结果与我在下面的请求中提供的“最大结果”值完全相同。
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;
输出为(100行),如:
$ VAR1 = bless({'_ protot'=>'HTTP / 1.1','_ content'=>'userEMAIL2014-02-27T02:15:52.254ZuserNAMEuserEMAILContacts10361100http://www.google.com/m8/feeds /contacts/userEMAIL/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 /馈送/联系人/ USEREMAIL /碱/ 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/userEMAIL/base/42008-04- ...
答案 0 :(得分:0)
$response
返回的make_restricted_request
是HTTP::Response
个对象。 Net::OAuth::Simple
已检查请求是否成功,因此您可以使用$response->content
或$response->decoded_content
访问回复内容。