1
for ($x = 1 ; $x <= 100 ; $x++) {

        $file = "http://urlishere?parameter1={$x}"

        //An example JSON string.
        $jsonString = file_get_contents($file);

        // Additional processing here
}

执行上述操作偶尔会引发警告:警告:file_get_contents(...): failed to open stream: HTTP request failed!HTTP/1.1 429 请求过多

我可以使用 sleep() 在每次调用 file_get_contents 之间创建一个间隔吗?如果不是,我还能做些什么来解决这个问题?

另外,我如何转储有关在下一个请求之前等待多长时间的详细信息:https ://httpstatuses.com/429

我可以使用 file_get_contents 吗?

4

0 回答 0