1

所以我之前在 Google AdWords API 中使用ClientLogin进行授权,但是在查看AuthForInstalledApps之后,它说这种机制已被弃用,取而代之的是OAuth2.0

我已经在API Consoles中注册了我的应用程序。现在我正在尝试按照 perl 示例进行设置:

使用_oauth2.pl

我无法将 AdWords 客户端、凭据放在 ~/adwords.properties中,因为我有多个帐户,我将对其进行广告系列管理操作,因此有多个客户端 ID。

但是现在我试图通过只使用我的一个客户的信息来遵循这个例子,如下所示:

my $client = Google::Ads::AdWords::Client->new(
    {
        version  => 'v201206',
        developer_token => TOKEN,
        client_id => $google_account_id
    }
);

$client->get_auth_token_handler()->set_email($login);
$client->get_auth_token_handler()->set_password($password);

但是,当我逐步执行此操作时,当它尝试初始化Client对象时会引发此错误:

Can't use an undefined value as a HASH reference at (eval 845)[/usr/lib/perl5/vendor_perl/5.8.8/HTTP/Message.pm:371] line 1. at (eval 845)[/usr/lib/perl5/vendor_perl/5.8.8/HTTP/Message.pm:371] line 1
HTTP::Message::__ANON__[(eval 845)[/usr/lib/perl5/vendor_perl/5.8.8/HTTP/Message.pm:371]:1]() called at /home/etienne/backend/libs/Google/Ads/Common/HTTPTransport.pm line 30
Google::Ads::Common::HTTPTransport::client('Google::Ads::Common::HTTPTransport=HASH(0xb59b830)', 'Google::Ads::AdWords::Client=SCALAR(0x9b9bb60)') called at /home/etienne/backend/libs Google/Ads/AdWords/Client.pm line 180
Google::Ads::AdWords::Client::START('Google::Ads::AdWords::Client=SCALAR(0x9b9bb60)', 1, 'HASH(0xb582e70)') called at /usr/lib/perl5/site_perl/5.8.8/Class/Std/Fast.pm line 251
Class::Std::Fast::__ANON__[/usr/lib/perl5/site_perl/5.8.8/Class/Std/Fast.pm:252]() called at /usr/lib/perl5/site_perl/5.8.8/Class/Std/Fast.pm line 287
Class::Std::Fast::new('Google::Ads::AdWords::Client', 'HASH(0xb54c210)') called at /home/etienne/backend/search_marketing/data_exchange/lib/GoogleAPIv2.pm line 3555
GoogleAPIv2::get_adwords_client('GoogleAPIv2=HASH(0xb556d10)', 4202697829) called at /home/etienne/backend/search_marketing/data_exchange/lib/GoogleAPIv2.pm line 230
GoogleAPIv2::add_campaign('GoogleAPIv2=HASH(0xb556d10)', 'name', 'API Upgrade Test Campaign - 1348613850', 'google_account_id', 4202697829, 'account_id', 207, 'country_code', 'US', ...) called at google_add_campaign.t line 110
main::main() called at google_add_campaign.t line 26
scalar context return from CODE(0x9b909c0): *Class::Std::Fast::_cache
1..3

我正在使用Perl v5.8.8. 我已经安装了最新的Adwords Perl Client Library v2.7.2. 是否存在某种依赖问题?我该如何解决这个问题。您可以提供的任何信息都会非常有帮助。谢谢。

4

1 回答 1

0

看起来我只需要安装最新的HTTP/Message.pm v6.0.3模块,因为我安装的版本没有decode()传递给模块AUTOLOAD()中子例程的方法HTTP/Message.pm

于 2012-09-27T21:42:23.300 回答