PHP 做群发短信(短信接口连接问题)
来源:互联网 发布:2015淘宝新店扶持 编辑:程序博客网 时间:2024/06/05 18:55
首先写个方法:
function sendSMS($http,$username,$password,$sendmobile,$send_content){
$httpurl = $http;
$data = array
(
'USERNAME'=>$username, //用户账号
'PASSWORD'=>$password, //用户密码
'MOBILE'=>$sendmobile, //号码
'CONTENT'=> mb_convert_encoding($send_content,'GB2312','UTF-8'), //内容
);
$re= $this->postSMS($httpurl,$data); //POST方式提交
if(trim($re)>0)
{
return "success";
}
else
{
return "error";
}
}
function postSMS($httpurl,$data=''){
$row = parse_url($httpurl);
$host = $row['host'];
$port = isset($row['port']) ? $row['port']:80;
$file = $row['path'];
$post = '';
while (list($k,$v) = each($data))
{
$post .= ($k)."=".($v)."&";
}
$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);
}
}
PHP处理页面
$sendmobile = isset($_POST['mobile']) ? trim($_POST['mobile']) : '';
$hm_arr = explode(',', $sendmobile);
$sendtime = isset($time) ? strtotime($time) : $systime;
$sendcontent = isset($_POST['contentname']) ? trim($_POST['contentname']) : '';
$sendstatus = 1;
$sendsign = isset($_POST['sendsign']) ? trim($_POST['sendsign']) : '';
$send_content = $sendcontent.' --'.$sendsign;
$httpurl = $sms_config['httpurl'];
$username = $sms_config['username'];
$password = $sms_config['password'];
$balance_info = $balance->GetBlanceInfo($uid);
$balance_sy = $balance_info['balance_info']-$balance_info['rate'];
$rate = $balance_info['rate'];
if($balance_sy > $rate){
$hp = $balance->sendSMS($httpurl,$username,$password,$sendmobile,preg_replace('/\s+/','%20',$send_content));
if($hp == 'success'){
$sql_c = "update {$tablepre}sms_info set balance_info = '$balance_sy',amount = amount+'1' where userid = '$uid'";
$rs = $db->query($sql_c);
$sql_s = "update {$tablepre}company set corpname = '$sendsign' where userid = '$uid'";
$rs_s = $db->query($sql_s);
$sql = "insert into {$tablepre}sms_log (sendmobile,userid,sendtime,sendcontent,sendtype,sendstatus,sendmoney) values ('$sendmobile','$uid','$sendtime','$sendcontent','$sendtype','$sendstatus','$rate')";
$rs = $db->query($sql);
header("location:index.php?c=sigle_send_mess&s=1");
}else{
header("location:index.php?c=sigle_send_mess&s=2");
}
}else{
header("location:index.php?c=sigle_send_mess&s=3");
}
- PHP 做群发短信(短信接口连接问题)
- 通过短信猫群发短信
- 群发短信 发短信(带图片)
- 连接短信接口
- php短信接口开发(http协议)
- php短信接口源码
- php接入短信接口
- php 阿里短信接口
- 短信群发短信和短代码运动
- 群发短信“达人”—凌凯短信平台
- 群发短信
- 群发短信
- php调用短信接口,php发送短信接口
- php短信接口(阿里大鱼)
- E php短信平台接口
- php短信接口(基于商麦无限)
- php发送短信(调用阿里大鱼接口)
- 短信接口都是这样做的
- 使用FMDB-基本操作-
- varchar与char的区别
- Ext3 -- Form 实例。 用来migrate file 数据到DB用的
- 简析LIVE555中的延时队列
- WebSphere参考资料
- PHP 做群发短信(短信接口连接问题)
- java调用groovy类——修正版
- IBM WAS ND 分布式网络环境的理解与集群的实现
- handle中传递对象
- 15个注意事项决定程序员的未来
- pymongo api
- Blackbox报告:如何防止创业公司死于拔苗助长
- hibernate中的 bag
- ZOJ3209Treasure Map精确覆盖DLX