Sample code of php SMS interface (getting started)

WBOY
Release: 2016-07-25 08:56:29
Original
1854 people have browsed it
This article shares a piece of PHP SMS interface code. It is very simple and can be used as a reference for beginners. If the function of SMS interface is used in the website, this example can be used as a reference.

php SMS interface file:

$uid, //用户账号 'pwd'=>strtolower(md5($pwd)), //MD5位32密码 'mobile'=>$mobile, //号码 'content'=>$content, //内容 'time'=>$time, //定时发送 'mid'=>$mid //子扩展号 ); $re= postSMS($http,$data); //POST方式提交 if( trim($re) == '100' ) { return "发送成功!"; } else { return "发送失败! 状态:".$re; } } function postSMS($url,$data='') { $row = parse_url($url); $host = $row['host']; $port = $row['port'] ? $row['port']:80; $file = $row['path']; while (list($k,$v) = each($data)) { $post .= rawurlencode($k)."=".rawurlencode($v)."&"; //转URL标准码 } $post = substr( $post , 0 , -1 ); $len = strlen($post); $fp = @fsockopen( $host ,$port, $errno, $errstr, 10); if (!$fp) { return "$errstr ($errno)\n"; } else { $receive = ''; $out = "POST $file 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"; $out .= "Content-Length: $len\r\n\r\n"; $out .= $post; fwrite($fp, $out); while (!feof($fp)) { $receive .= fgets($fp, 128); } fclose($fp); $receive = explode("\r\n\r\n",$receive); unset($receive[0]); return implode("",$receive); } } ?>
Copy after login
You may also like:php SMS sending function Example code of php SMS interface function


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!