php短信接口源码,比较简单,但也实用
上次我寫過一段php調用webserver的短信接口原碼,今天把php的調用http的奉獻一下,比較簡單,但還是實用的
?
//短信接口同樣是調用http://www.56dxw.com 的
<?php
error_reporting(0);
header("content-type:text ml;charset=utf-8");
//帳號配置文件
$comid= "123"; //企業ID
$username= "dfhgtye"; //用戶名
$userpwd= "5656"; //密碼
$smsnumber= "1061"; //所用平臺
$handtel = $_GET["tel"];
$sendcontent = $_GET["content"];;
!$handtel && die('手機號必填');
!$sendcontent && die('發生內容必填');
function rstr($str){
?$s=intval(substr($str,0,1));
?if($s==1)
? $error='代表發送成功';
?else{
? $b=intval(substr($str,0,2));
? switch($b){
?? case -1:$error='手機號碼不正確';break;
?? case -2:$error='除時間外,所有參數不能為空';break;
?? case -3:$error='用戶名密碼不正確';break;
?? case -4:$error='平臺不存在';break;
?? case -5:$error='客戶短信數量為0';break;
?? case -6:$error='客戶賬戶余額小于要發送的條數';break;
?? case -7:$error='不能超過70個字';break;
?? case -8:$error='非法短信內容';break;
?? case -9:$error='未知系統故障';break;
?? case -10:$error='網絡性錯誤';break;
?? default:$error=false;
? }
?}
?return $error;
}
function sendnote($mobtel,$msg){
?global $username,$userpwd,$smsnumber,$comid;
?$url = "http://jiekou.56dxw.com/sms/HttpInterface.aspx?comid=$comid&username=$username&userpwd=$userpwd&handtel=$mobtel&sendcontent=$msg&sendtime=&smsnumber=$smsnumber";
?$string = file_get_contents($url);
?return? rstr($string);
}
$msg='內容限制為70個字,';
$msg=mb_convert_encoding($msg, 'gb2312' ,'utf-8');
echo sendnote($handtel,$msg);
?>
轉載于:https://www.cnblogs.com/ydysl2012/archive/2012/01/06/2315196.html
總結
以上是生活随笔為你收集整理的php短信接口源码,比较简单,但也实用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 有社保怎么申请无抵押贷款
- 下一篇: IE6中Form.submit不提交的问