$data["name"] = 'godlike';
$data["age"] = 18;
$post = http_build_query($data);
$len = strlen($post);
$host = "www.example.com";
$path = "/member/lackGoods/sendSmsAll";
$errno ='';
$errstr='';
$fp = fsockopen($host,80,$errno,$errstr,30);
if (!$fp) {
echo "$errstr ($errno) ";
} else {
$out = "POST $path HTTP/1.1 "; //通过POST方式
$out .= "Host: $host ";
$out .= "Content-type: application/x-www-form-urlencoded ";
$out .= "Connection: Close ";
$out .= "Content-Length: $len ";
$out .= " ";
$out .= $post . " ";
fwrite($fp, $out);
// while (!feof($fp)) {
// $receive .= fgets($fp, 128);
// }
fclose($fp);
}
public function sendSmsAll()
{
var_dump($_POST);
//发送短信的方法
}
//还可以使用curl实现
$ch = curl_init();
$curl_opt = array(CURLOPT_URL, 'http://www.example.com/backend.php',
CURLOPT_RETURNTRANSFER, 1,
CURLOPT_TIMEOUT, 1,);
curl_setopt_array($ch, $curl_opt);
curl_exec($ch);
curl_close($ch);