调用 Twitter API 会导致"Timestamp out of bounds"错误



我正在调用Twitter以获取用户的时间轴详细信息。这是我的代码

$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=twitterapi",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "authorization: OAuth oauth_consumer_key="XXXXXXX",oauth_token="XXXXXXX",oauth_signature_method="HMAC-SHA1",oauth_timestamp="XXXXXXX",oauth_nonce="XXXXXXXX",oauth_version="1.0",oauth_signature="XXXXXXX"",
      "cache-control: no-cache"
  ),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}    

我能够获取详细信息。但是一天后我得到了这个回复

{"错误":

[{"代码":135,"消息":"时间戳越界。

我的代币会过期吗?我想将此代码作为后台请求运行。

oauth_timestamp应该是自 1970 年 1 月 1 日 00:00:00 UTC 以来的整数秒数。

{"错误":

[{"代码":135,"消息":"时间戳越界。

通常意味着您的服务器/机器时间偏差超过 30 秒(实际时间不包括时区差异(。查看响应标题,了解Twitter的时间是多少。

oauth_timestamp=1521786006

最新更新