执行后重启php / curl脚本

时间:2018-03-10 09:32:34

标签: php curl restart

我对带有分页的api有一个curl请求,现在我想多次执行我的php脚本,这样我就不必用不同的页面号手动启动它了

$endpoint = 'https://xxx.weclapp.com/webapp/api/v1/';
$api_token = 'xxx';
$articlePerPage = 100;
$currentPage = 1;
$amountOfArticles = "different curl get request (approx 1100)"
$amountOfPages = ceil($amountOfArticles / $articlePerPage);
$header = array();
$header[] = 'Content-type: application/json';
$header[] = 'AuthenticationToken:'.$api_token;
curl_setopt($curl, CURLOPT_HTTPHEADER,$header);
curl_setopt($curl, CURLOPT_URL,$endpoint.'article/?page='.$currentPage.'&pageSize='.$articlePerPage);
curl_setopt($curl, CURLOPT_HTTPGET, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$JSON = curl_exec($curl);
$result = json_decode($JSON);

我试图把它放在while循环中

while ($currentPage <= $amountOfPages) : ...; endwhile;

但不幸的是,分别需要很多产品需要很长时间,所以我的服务器无法完成所有这些通话而且我得到了504

目前我每次使用不同的$ currentPage编号手动启动此脚本12次。我的想法是让服务器完成脚本,然后用$ currentPage ++重新启动它,但我不知道如何做到这一点。

我已经使用bin / bash脚本阅读了有关此主题9798438的解决方案,但之后我无法更改$ currentPage变量

有没有人知道如何管理我想要做的事情?

非常感谢,我很感激任何帮助

亚历

0 个答案:

没有答案
相关问题