1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- /**
- * 批量发送短信
- * @author >
- * @param $args[0] 发送数量限制
- * @param /download/need_sms.txt 需要发送短信的用户信息
- */
- class SendSMSCommand extends CConsoleCommand{
- public function run($args) {
- if(isset($args[0])){
- $send_num = $args[0];
- }else{
- $send_num = 3000;
- }
- $file = file_get_contents(APP_PATH.'/download/need_sms.txt');
- $smsservice = Service::factory('SendSMSService');
- $info_arr = explode("\n",$file);
- $i = 1;
- foreach ($info_arr as $key => $value) {
- if($i>$send_num){
- break;
- }
- $user_info = explode("----", $value);
- if(preg_match("/\d{11}/", $user_info[1])){
- $user_info[1] = trim($user_info[1]);
- $result = $smsservice->send_sms('【壹管家】炎热酷暑,清凉一夏,下载壹管家APP即获248元优惠大礼包,猛戳 http://dwz.cn,回T退订',$user_info[1]);
- if($i==1000){
- $result = $smsservice->send_sms('【壹管家】炎热酷暑,清凉一夏,下载壹管家APP即获248元优惠大礼包,回T退订','18521093629');
- $result = $smsservice->send_sms('【壹管家】炎热酷暑,清凉一夏,下载壹管家APP即获248元优惠大礼包,','18817554864');
- }
- echo $i++;
- echo iconv('utf-8', 'gbk', $result);
- echo "\r\n";
- if($result){
- unset($info_arr[$key]);
- }
- }else{
- unset($info_arr[$key]);
- }
- }
- $result_str = implode("\n",$info_arr);
- file_put_contents(APP_PATH.'/download/need_sms.txt',$result_str);
- }
- }
|