0

我正在尝试为我的推文获得回复。我使用 Net::Twitter::Lite:

my $nt = Net::Twitter::Lite->new(%consumer_tokens, %access_tokens, legacy_lists_api=>1);
my $mentions = $nt->mentions();
print Dumper $mentions;

但在那之后我只有一个错误:无法使用 OAuth 进行身份验证。有任何想法吗?

我可以发布类似的推文: my $status = $nt->update({ status => 'some text' }); 但我无法得到回复。

更新

工作:

#!/usr/bin/perl
use warnings;
use strict;
use Net::Twitter::Lite;
use Data::Dumper;

my %consumer_tokens = (
consumer_key    => 'xxxxxxxxxxxxxxxxxxxxxxxx',
consumer_secret => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
);
my %access_tokens=(
access_token => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
access_token_secret => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
);

my $nt = Net::Twitter::Lite->new(%consumer_tokens, %access_tokens, legacy_lists_api=>1);

#217932132083970049
my $status = $nt->update({ status => 'Happy Perl People!' });
print Dumper $status;

不工作:

#!/usr/bin/perl
use warnings;
use strict;
use Net::Twitter::Lite;
use Data::Dumper;

my %consumer_tokens = (
consumer_key    => 'xxxxxxxxxxxxxxxxxxxxxxxx',
consumer_secret => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
);
my %access_tokens=(
access_token => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
access_token_secret => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
);

my $nt = Net::Twitter::Lite->new(%consumer_tokens, %access_tokens, legacy_lists_api=>1);

#217932132083970049
my $mentions = $nt->mentions();
print Dumper $mentions;
4

1 回答 1

0

首先它注册api并生成信息,修改脚本并列出

use strict;
use warnings;
use Net::Twitter::Lite;

my $nt = Net::Twitter::Lite->new(
  consumer_key        => 'key_here', #first 
  consumer_secret     => 'consumer_secret_here', #
  access_token        => 'access_token', #second, generate token 
  access_token_secret =>  'access_token_secret', # 
  legacy_lists_api => 0,
);

my $result = eval { $nt->update('otra prueba') };

warn "$@\n" if $@;
于 2012-09-07T03:58:04.383 回答