<?PHP
header("Content-Type: text/html; charset=UTF-8");
$flag = 0;
$params='';//要post的數(shù)據(jù)
$verify = rand(123456, 999999);//獲取隨機驗證碼
//以下信息自己填以下
$mobile='';//手機號
$argv = array(
'name'=>'', //必填參數(shù)。用戶賬號
'pwd'=>'', //必填參數(shù)。(web平臺:基本資料中的接口密碼)
'content'=>'短信驗證碼為:'.$verify.',請勿將驗證碼提供給他人。', //必填參數(shù)。發(fā)送內容(1-500 個漢字)UTF-8編碼
'mobile'=>$mobile, //必填參數(shù)。手機號碼。多個以英文逗號隔開
'stime'=>'', //可選參數(shù)。發(fā)送時間,填寫時已填寫的時間發(fā)送,不填時為當前時間發(fā)送
'sign'=>'', //必填參數(shù)。用戶簽名。
'type'=>'pt', //必填參數(shù)。固定值 pt
'extno'=>'' //可選參數(shù),擴展碼,用戶定義擴展碼,只能為數(shù)字
);
//print_r($argv);exit;
//構造要post的字符串
//echo $argv['content'];
foreach ($argv as $key=>$value) {
if ($flag!=0) {
$params .= "&";
$flag = 1;
}
$params.= $key."="; $params.= urlencode($value);// urlencode($value);
$flag = 1;
}
$url = "http://web.cr6868.com/asmx/smsservice.aspx?".$params; //提交的url地址
$con= substr( file_get_contents($url), 0, 1 ); //獲取信息發(fā)送后的狀態(tài)
if($con == '0'){
echo "<script>alert('發(fā)送成功!');</script>";
}else{
echo "<script>alert('發(fā)送失敗!');history.back();</script>";
}
?>