标签:
$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)\n";
} else {
$out = "POST $path HTTP/1.1\r\n"; //通过POST方式
$out .= "Host: $host\r\n";
$out .= "Content-type: application/x-www-form-urlencoded\r\n";
$out .= "Connection: Close\r\n";
$out .= "Content-Length: $len\r\n";
$out .= "\r\n";
$out .= $post . "\r\n";
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);
标签:
原文地址:http://www.cnblogs.com/godLike7/p/5606476.html