我在这个php curl多次请求中被困2小时
我想让帖子json数据从1111(这是一个起点和验证码)开始到1121(终点1111 + $ process_count)
检查一下这些人:
GROUP BY username
ORDER BY
但是 curl_setopt($ ch,CURLOPT_POSTFIELDS,$ str_verification);总是给出终点值1121。
并且没有循环
从1111年到1121年。
任何人都可以搞清楚吗?我很乐意提供任何帮助
答案 0 :(得分:0)
你在第一个循环中出错了,你每次只将数据删除到一个变量而不是数组
$str_verification = json_encode($data_verification);
我建议你这样做:
$str_verification = array();
for($c=1111;$c <= 1121;$c++){
$data_verification = array(
"phone" => "+6285643103039", // +6285643103039 9025
"verificationCode" => $c
);
$str_verification[] = json_encode($data_verification);
}
for ($i = 0; $i != 10; $i++)
{
$ch = curl_init($url);
$headers= array('Accept: application/json','Content-Type: application/json');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
curl_setopt($ch, CURLOPT_TIMEOUT, 4000);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS,$str_verification[$i]);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
ob_start();
curl_multi_add_handle($mh, $ch);
$handles[] = $ch;
}