[英]curl_multi_exec does not call remote function
I have a Utility class that has to invoke a remote cPanel URL to create an email forwarding address, via cURL. 我有一个Utility类,该类必须通过cURL调用远程cPanel URL来创建电子邮件转发地址。 This works perfectly well if I use regular curl_exec but fails if I try to make it non-blocking via curl_multi_exec - All I need to do is send a request and move on, I dont need to know the result - so it is a truly non-blocking requirement
如果我使用常规curl_exec,这将很好地工作,但是如果我尝试通过curl_multi_exec使它成为非阻塞,则将失败-我要做的就是发送请求并继续前进,我不需要知道结果-因此,这是真正的非封锁要求
Here is the code that works 这里是工作的代码
$url = "https://mycpanel.com:2083/execute/Email/add_forwarder?domain=mydomain.com&email=email_fwd_146&fwdopt=pipe&pipefwd=php/piper.php&";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Basic " . base64_encode("user:pwd")));
$response = curl_exec($ch);
CakeLog::write('error', print_r($response, true));
curl_close($ch);
The response I get for above code is below (even though I really dont care about the response) 我对以上代码的响应如下(即使我真的不在乎响应)
{
"messages":null,
"errors":null,
"status":1,
"metadata":{
"transformed":1
},
"data":[
{
"email":"email_fwd_146@mydomain.com",
"domain":"mydomain.com",
"forward":"|/home/myconsole/php/piper.php"
}]
}
Here is the code that does not work 这是无效的代码
$url = "https://mycpanel.com:2083/execute/Email/add_forwarder?domain=mydomain.com&email=email_fwd_146&fwdopt=pipe&pipefwd=php/piper.php&";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Basic " . base64_encode("user:pwd")));
$mh = curl_multi_init();
curl_multi_add_handle($mh,$ch);
curl_multi_exec($mh, $active);
This call never seems to reach the server or even execute. 该调用似乎永远不会到达服务器甚至无法执行。 Any insight will be appreciated.
任何见识将不胜感激。
这是因为需要一遍又一遍地调用curl_multi_exec ()直到传输完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.