Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用fsockopen,如何在不等待API返回的情况下异步调用API?_Php_Asynchronous_Curl_Fsockopen - Fatal编程技术网

Php 使用fsockopen,如何在不等待API返回的情况下异步调用API?

Php 使用fsockopen,如何在不等待API返回的情况下异步调用API?,php,asynchronous,curl,fsockopen,Php,Asynchronous,Curl,Fsockopen,我使用此代码段异步调用API: 公共函数postUrlAsync($url) { $post_字符串=“”; $parts=parse_url($url); 如果(!empty($parts['query'])){ $queryParams='?。$parts['query']; } $fp=fsockopen($parts['host'],isset($parts['port'])?$parts['port']:80,$errno,$errstr,90); 如果($fp

我使用此代码段异步调用API:

公共函数postUrlAsync($url)
{           
$post_字符串=“”;
$parts=parse_url($url);
如果(!empty($parts['query'])){
$queryParams='?。$parts['query'];
}
$fp=fsockopen($parts['host'],isset($parts['port'])?$parts['port']:80,$errno,$errstr,90);
如果($fp){
$out=“POST”。$parts['path'].$queryParams。“HTTP/1.1\r\n”;
$out.=“主机:”.$parts[“主机”]。“\r\n”;
$out.=“内容类型:应用程序/x-www-form-urlencoded\r\n”;
$out.=“内容长度:”.strlen($post\u字符串)。“\r\n”;
$out.=“Referer:”.$this->app\u config['checkout\u processor\u url']。“\r\n”;
$out.=“连接:关闭\r\n\r\n”;
$result=fwrite($fp,$out);
fclose($fp);
返回$result;
}
}
}