for ($x = 1 ; $x <= 100 ; $x++) {
$file = "http://urlishere?parameter1={$x}"
//An example JSON string.
$jsonString = file_get_contents($file);
// Additional processing here
}
Executing the above has occasionally thrown a warning with: Warning: file_get_contents(...): failed to open stream: HTTP request failed! HTTP/1.1 429 Too Many Requests
Can I use sleep() to create an interval between each call of file_get_contents? If no, what else can I do to solve the problem?
Also, how do I dump the details on how long to wait before the next request as per: https://httpstatuses.com/429
Can I use file_get_contents?