当前位置: 首页>>代码示例>>PHP>>正文


PHP Sms::send_SMS方法代码示例

本文整理汇总了PHP中Sms::send_SMS方法的典型用法代码示例。如果您正苦于以下问题:PHP Sms::send_SMS方法的具体用法?PHP Sms::send_SMS怎么用?PHP Sms::send_SMS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sms的用法示例。


在下文中一共展示了Sms::send_SMS方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sendSms

 /**
  * 
  * 批量发送短信
  * @param array $mobile 手机号码
  * @param string $content 短信内容
  * @param datetime $send_time 发送时间
  * @param string $charset 短信字符类型 gbk / utf-8
  * @param string $id_code 唯一值 、可用于验证码
  */
 public function sendSms($token, $content = '', $mobile = '', $send_time = '', $charset = 'utf-8', $id_code = '')
 {
     $companyid = 0;
     if (!(strpos($token, '_') === FALSE)) {
         $sarr = explode('_', $token);
         $token = $sarr[0];
         $companyid = intval($sarr[1]);
     }
     if (!$mobile) {
         $companyWhere = array();
         $companyWhere['token'] = $token;
         if ($companyid) {
             $companyWhere['id'] = $companyid;
         }
         $company = M('Company')->where($companyWhere)->find();
         $mobile = $company['mp'];
     }
     //
     $thisWxUser = M('Wxuser')->where(array('token' => Sms::_safe_replace($token)))->find();
     $thisUser = M('Users')->where(array('id' => $thisWxUser['uid']))->find();
     if ($token == 'admin') {
         $thisUser = array('id' => 0);
         $thisWxUser = array('uid' => 0, 'token' => $this->token);
     }
     if ($thisUser['smscount'] < 1) {
         return '已用完或者未购买短信包';
         //exit();
     } else {
         //
         //短信发送状态
         if (is_array($mobile)) {
             $mobile = implode(",", $mobile);
         }
         $content = Sms::_safe_replace($content);
         $data = array('topdomain' => C('server_topdomain'), 'key' => C('sms_key'), 'token' => $token, 'content' => $content, 'mobile' => $mobile, 'mobileids' => '11');
         $post = '';
         foreach ($data as $k => $v) {
             $post .= $k . '=' . $v . '&';
         }
         //短信URL地址
         //$smsapi_senturl = 'http://up.pigcms.cn/oa/admin.php?m=sms&c=sms&a=send';
         $smsapi_senturl = C('sms_url');
         $uid = C('uid');
         $pwd = C('pwd');
         $mobile = $data['mobile'];
         $content = $data['content'];
         $mobileids = C('mobileids');
         //$return = Sms::_post($smsapi_senturl, 0, $post);
         $return = Sms::send_SMS($smsapi_senturl, $uid, $pwd, $mobile, $content, $mobileids);
         $arr = explode('&', $return);
         $sta = explode("=", $arr[1]);
         $this->statuscode = $sta[1];
         //增加到本地数据库
         $row = array('uid' => $thisUser['id'], 'token' => $thisWxUser['token'], 'time' => time(), 'mp' => $mobile, 'text' => $content, 'status' => $this->statuscode, 'price' => C('sms_price'));
         M('Sms_record')->add($row);
         if (intval($this->statuscode) == 100 && $token != 'admin') {
             M('Users')->where(array('id' => $thisWxUser['uid']))->setDec('smscount');
         }
         //end
         //print_r($return);
         //exit;
         return $this->statuscode;
     }
 }
开发者ID:ww102111,项目名称:weixin,代码行数:73,代码来源:Sms.class.php

示例2: sendSms

 /**
  * 
  * 批量发送短信
  * @param array $mobile 手机号码
  * @param string $content 短信内容
  * @param datetime $send_time 发送时间
  * @param string $charset 短信字符类型 gbk / utf-8
  * @param string $id_code 唯一值 、可用于验证码
  * $data = array(mer_id, store_id, content, mobile, uid, type);
  */
 public function sendSms($data = array(), $send_time = '', $charset = 'utf-8', $id_code = '')
 {
     if ($data) {
         $type = isset($data['type']) ? $data['type'] : 'meal';
         $sendto = isset($data['sendto']) ? $data['sendto'] : 'user';
         $mer_id = isset($data['mer_id']) ? intval($data['mer_id']) : 0;
         $store_id = isset($data['store_id']) ? intval($data['store_id']) : 0;
         $uid = isset($data['uid']) ? intval($data['uid']) : 0;
         if (empty($mer_id)) {
             return 'mer_id is null';
         }
         $content = isset($data['content']) ? Sms::_safe_replace($data['content']) : '';
         if (empty($content)) {
             return 'send content is null';
         }
         $mobile = isset($data['mobile']) ? $data['mobile'] : '';
         $phone_array = explode(',', $mobile);
         $mobile = $pre = '';
         foreach ($phone_array as $phone) {
             if (Sms::checkmobile($phone)) {
                 $mobile .= $pre . $phone;
                 $pre = ',';
             }
         }
         if (empty($mobile)) {
             return 'phone is right';
         }
         $data = array('topdomain' => C('config.sms_server_topdomain'), 'key' => trim(C('config.sms_key')), 'token' => $mer_id . 'o2opigcms', 'content' => $content, 'mobile' => $mobile, 'sign' => trim(C('config.sms_sign')));
         $post = '';
         foreach ($data as $k => $v) {
             $post .= $k . '=' . $v . '&';
         }
         $http = 'http://api.sms.cn/mtutf8/';
         $uid = C('config.sms_key');
         $pwd = C('config.sms_sign');
         $mobile = $mobile;
         $content = $content;
         $mobileids = $mobile;
         // dump($mobileids);exit;
         $return = Sms::send_SMS($http, $uid, $pwd, $mobile, $content, $mobileids);
         //dump($return);exit;
         $arr = explode('#', $return);
         $send_time = $send_time ? $send_time : time();
         //增加到本地数据库
         $row = array('mer_id' => $mer_id, 'uid' => $uid, 'store_id' => $store_id, 'time' => $send_time, 'phone' => $mobile, 'text' => $content, 'status' => $return, 'type' => $type, 'sendto' => $sendto);
         D('Sms_record')->add($row);
         return $return;
     } else {
         return false;
     }
     exit;
     if (C('sms_key') != '' && C('sms_key') != 'key') {
         $companyid = 0;
         if (!(strpos($token, '_') === FALSE)) {
             $sarr = explode('_', $token);
             $token = $sarr[0];
             $companyid = intval($sarr[1]);
         }
         if (!$mobile) {
             $companyWhere = array();
             $companyWhere['token'] = $token;
             if ($companyid) {
                 $companyWhere['id'] = $companyid;
             }
             $company = M('Company')->where($companyWhere)->find();
             $mobile = $company['mp'];
         }
         //
         $thisWxUser = M('Wxuser')->where(array('token' => Sms::_safe_replace($token)))->find();
         $thisUser = M('Users')->where(array('id' => $thisWxUser['uid']))->find();
         if ($token == 'admin') {
             $thisUser = array('id' => 0);
             $thisWxUser = array('uid' => 0, 'token' => $this->token);
         }
         //
         //短信发送状态
         if (is_array($mobile)) {
             $mobile = implode(",", $mobile);
         }
         $content = Sms::_safe_replace($content);
         $data = array('topdomain' => C('config.server_topdomain'), 'key' => trim(C('config.sms_key')), 'token' => $token, 'content' => $content, 'mobile' => $mobile, 'sign' => trim(C('config.sms_sign')));
         $post = '';
         foreach ($data as $k => $v) {
             $post .= $k . '=' . $v . '&';
         }
         $http = 'http://api.sms.cn/mtutf8/';
         $uid = C('config.sms_key');
         $pwd = C('config.sms_sign');
         $mobile = $mobile;
         $content = $content;
//.........这里部分代码省略.........
开发者ID:belerweb,项目名称:pigcms,代码行数:101,代码来源:Sms.class.php


注:本文中的Sms::send_SMS方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。