2014-09-28 74 views
0

我正在尝试做一个简单的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.\n\nPIN: "; 
} 

与以下错误的NT-$> get_authorization_url行的代码失败:

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

这是没有意义的我,为什么它要求被授权为了获得授权URL ...

+1

你检查了你的时间戳吗? – Leistungsabfall 2014-09-28 14:51:09

+0

我的时间戳? – Dendory 2014-09-28 15:14:22

回答

1

Doh发现原因,这是当我的虚拟机的时钟设置得太远时会发生什么。感谢提及Leistungsabfall的时间戳让我想起检查,并且我希望Twitter错误信息更有意义。