Updated to the “lib” version
This commit is contained in:
parent
5bc85ba20f
commit
51b356bf14
1 changed files with 2 additions and 5 deletions
|
@ -19,17 +19,14 @@ function ckratelimit($headers) {
|
||||||
if (!is_int($reset)) return ['ok'=>false,'error'=>'«x-ratelimit-reset» header could not be converted to a unix timestamp'];
|
if (!is_int($reset)) return ['ok'=>false,'error'=>'«x-ratelimit-reset» header could not be converted to a unix timestamp'];
|
||||||
// don't do the one on the line below, since it happens lots of times
|
// don't do the one on the line below, since it happens lots of times
|
||||||
//if ($reset<$date) return ['ok'=>false,'error'=>'the unix timestamp parsed from «x-ratelimit-reset» header is less than the unix timestamp parsed from «date» header'];
|
//if ($reset<$date) return ['ok'=>false,'error'=>'the unix timestamp parsed from «x-ratelimit-reset» header is less than the unix timestamp parsed from «date» header'];
|
||||||
if ($remaining==0)
|
return ['ok'=>true,'sleep'=>$reset-$date+1,'remaining'=>$remaining];
|
||||||
return ['ok'=>true,'sleep'=>$reset-$date+1,'remaining'=>$remaining];
|
|
||||||
else
|
|
||||||
return ['ok'=>true,'sleep'=>0,'remaining'=>$remaining];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// test
|
// test
|
||||||
$context=[
|
$context=[
|
||||||
'http'=>[
|
'http'=>[
|
||||||
'header'=>'Accept: application/json'.RN
|
'header'=>"Accept: application/json\r\n";
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
$context=stream_context_create($context);
|
$context=stream_context_create($context);
|
||||||
|
|
Loading…
Reference in a new issue