php使用stream_socket_client发送异步请求
public function sockPost($host,$path,$params){
$query =http_build_query($params);
// $fp = fsockopen('ssl://'.$host, 443, $errno, $errstr, 60);
$fp = stream_socket_client('ssl://'.$host.':443', $errno, $errstr, 60);
$head = "POST ".$path."?".$query." HTTP/1.0\r\n";
$head .= "Host: ".$host."\r\n";
$head .= "Referer: https://".$host.$path."\r\n";
$head .= "Content-type: application/x-www-form-urlencoded\r\n";
$head .= "Content-Length: ".strlen(trim($query))."\r\n";
$head .= "\r\n";
$head .= trim($query)."\r\n";
$write = fwrite($fp, $head);
fclose($fp);
}
欢迎交流指点!我的微信: