奇怪的Twitter授权错误



我正在尝试做一个简单的Twitter发布脚本,但得到了一些奇怪的结果。这是相关代码:

if ( $access_token eq "" || $access_token_secret eq "" ) {
    $nt = Net::Twitter->new(
        traits          => [qw/API::RESTv1_1 OAuth/],
        consumer_key    => $app_key,
        consumer_secret => $app_secret,
        ssl             => 1,
    );
} else {
    $nt = Net::Twitter->new(
        traits              => [qw/API::RESTv1_1 OAuth/],
        consumer_key        => $app_key,
        consumer_secret     => $app_secret,
        access_token        => $access_token,
        access_token_secret => $access_token_secret,
        ssl                 => 1,
    );
}
if ( !$nt->authorized ) {
    print "You must authorize this app at ", $nt->get_authorization_url, " and enter the PIN below.nnPIN: ";
}

代码在$nt->get_authorization_url行失败,并出现以下错误:

Net::Twitter::Role::Oauth::get_authorization_url(): GET https://api.twitter.com/oauth/request_token failed: 401 Unauthorized

这对我来说毫无意义,为什么它要求获得授权才能获得授权URL。。。

Doh发现了原因,这就是当我的VM的时钟设置得太晚时会发生的情况。感谢你向Leistungsabfall提到时间戳,让我考虑检查一下,我希望推特上的错误消息更有意义。

最新更新