使用fsockopen 异步
function SyncJob($url, $port = 80, $time = 30,$debug = false)
{
$url_str = str_replace(array('http://', 'https://'), '', $url);
$location = strpos($url_str, '/');
$host = substr($url_str, 0, $location);
$fp = fsockopen($host, $port, $errno, $errstr, $time);
if($fp)
{
$out = "GET ".str_replace($host, '', $url_str)." HTTP/1.1\r\n";
$out .= "Host: ".$host."\r\n";
$out .= "Content-type: application/x-www-form-urlencoded\r\n";
$out .= "Connection: Close\r\n\r\n";
fputs($fp, $out);
if($debug){
$somecontent=date("Y-m-d H:i:s");
$somecontent.="\r\n";
$handle = fopen("2.txt", 'a');
fwrite($handle, $somecontent);
fclose($handle);
}
fclose($fp);
}
}
SyncJob('www.cbjdhd.com/qq/PHPMailer.php');
echo json_encode(array('code'=>0,'msg'=>'发送成功!','data'=>array()));
exit();