您如何使用 Moo::Google Perl 模块进行 Google 人 API 调用?

How do you make Google People API calls with Moo::Google Perl module?

我正在尝试使用 Moo::Google 模块对 Google 的人员 API 进行 API 调用。我已经能够成功拨打简单的日历 API 电话,但无法拨打人员 API。我有以下代码尝试使用 People API:

#! /usr/bin/env perl
use Moo::Google;

my $gapi = Moo::Google->new(debug => 0);
my $user = 'me@gmail.com';

$gapi->auth_storage->setup({ type => 'jsonfile', path => 'config.json'
+ });
$gapi->user($user);
$gapi->do_autorefresh;

$gapi->People->People->get({'resourceName'  => 'people/me', 'personFields' => 'emailAddresses'})->json;

不过,这个returnsundefined。我试过可能不同的变化,但没有运气。

用低级方法解决,api_query():

#! /usr/bin/env perl
use Moo::Google;
use Data::Dumper qw (Dumper);

my $gapi = Moo::Google->new(debug => 0);
my $user = 'me@gmail.com';

$gapi->auth_storage->setup({ type => 'jsonfile', path => 'config.json' });
$gapi->user($user);
$gapi->do_autorefresh;

$res = $gapi->api_query( {
    httpMethod => 'get',
    path => 'https://people.googleapis.com/v1/people/me',
    options => { personFields => 'emailAddresses' }
});

print Dumper $res;

如果有更好的方法,我很想听听。