php模拟post请求,实现手机短信验证
2016-11-02 20:06
351 查看
下面的函数是直接封装好的post请求,需要两个参数 相信我注释很清楚了
/**
*响应信息(post)
*@url 请求地址
*@query 请求参数string类型
*/
/* protected function sock_post($url,$query){
$info=parse_url($url);
$fp=fsockopen($info["host"],80,$errno,$errstr,3);
$head="POST ".$info['path']." HTTP/1.0\r\n";
$head.="Host: ".$info['host']."\r\n";
$head.="Referer: http://".$info['host'].$info['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);
$write=fputs($fp,$head);
while(!feof($fp)){
$line=fgets($fp);
echo $line."<br>";
}
}*/
//调用实力 //$mobile是手机号 拿到了请求参数 传入手机号就能发送短信了
function read($mobile){
$url = "http://www.ztsms.cn/sendNSms.*****";
$name = '****';
$tkey = date('YmdHis');
$pass = md5(md5('***').$tkey);
$mobile = $mobile;
$content = "此次注册验证码$this->$captcha(验证码有效期30分钟)【*****】";
$productid = '****';
$xh = '';
$parameter = "username=$name&password=$pass&tkey=$tkey&mobile=$mobile&content=$content&productid=$productid&xh=";
return $this->sock_post($url,$parameter);
}
/**
*响应信息(post)
*@url 请求地址
*@query 请求参数string类型
*/
/* protected function sock_post($url,$query){
$info=parse_url($url);
$fp=fsockopen($info["host"],80,$errno,$errstr,3);
$head="POST ".$info['path']." HTTP/1.0\r\n";
$head.="Host: ".$info['host']."\r\n";
$head.="Referer: http://".$info['host'].$info['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);
$write=fputs($fp,$head);
while(!feof($fp)){
$line=fgets($fp);
echo $line."<br>";
}
}*/
//调用实力 //$mobile是手机号 拿到了请求参数 传入手机号就能发送短信了
function read($mobile){
$url = "http://www.ztsms.cn/sendNSms.*****";
$name = '****';
$tkey = date('YmdHis');
$pass = md5(md5('***').$tkey);
$mobile = $mobile;
$content = "此次注册验证码$this->$captcha(验证码有效期30分钟)【*****】";
$productid = '****';
$xh = '';
$parameter = "username=$name&password=$pass&tkey=$tkey&mobile=$mobile&content=$content&productid=$productid&xh=";
return $this->sock_post($url,$parameter);
}
相关文章推荐
- PHP手机短信验证码实现流程详解
- PHP fsockopen介绍及fsockopen封装函数实现模拟GET或POST请求
- 容联云通讯实现php的手机发送短信验证
- php实现模拟post请求用法实例
- PHP接口实现手机短信验证
- PHP 手机短信验证码 laravel 实现流程
- php实现模拟post请求用法实例
- PHP模拟表单的post请求实现登录
- php模拟POST请求的两种方法
- php模拟点击器,刷新,清除ie的get和post请求
- PHP中使用cURL实现Get和Post请求
- PHP中使用cURL实现Get和Post请求的方法
- C#(WINFORM)实现模拟POST发送请求登录网站
- php+socket模拟get,post请求
- PHP中使用cURL实现Get和Post请求的方法
- python 实现发送手机短信验证码后台方法
- PHP中使用CURL实现Get和Post请求的方法
- PHP中使用cURL实现Get和Post请求
- Java调用WebService接口实现发送手机短信验证码功能,java 手机验证码,WebService接口调用
- PHP中使用cURL实现Get和Post请求的方法