cURL错误(28):操作在201毫秒后收到0字节时超时
这是我的代码:
if (!isset($_GET['foo'])) {
// Client
$pIds = array("All");
$data = array("apiToken" => "apitoken-3D", "productIds" => $pIds);
$data_string = json_encode($data);
//echo $data_string;
$ch = curl_init('http://myurl/WriteProductData');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 200);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($data_string))
);
$data = curl_exec($ch);
//var_dump(json_decode($data, true));
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
curl_close($ch);
if ($curl_errno > 0) {
echo "cURL Error ($curl_errno): $curl_error\n";
} else {
echo "Data received: $data\n";
} else {
// Server
sleep(10);
echo "Done.";
}
上面不是真正的API密钥等,但只是想让你看到代码。
请告知如何解决此问题,以及如何解决此问题。如有必要,我们可以在服务器上进行调整。