作者 何书鹏
1 个管道 的构建 通过 耗费 1 秒

短信

@@ -50,18 +50,32 @@ class Sms extends Api @@ -50,18 +50,32 @@ class Sms extends Api
50 // $ret = Smslib::send($mobile, null, $event); 50 // $ret = Smslib::send($mobile, null, $event);
51 $ret = $this->getCode($mobile, null, $event); 51 $ret = $this->getCode($mobile, null, $event);
52 if ($ret) { 52 if ($ret) {
53 - $this->success(__('发送成功'),['code'=>$ret]); 53 + $this->success(__('发送成功'));
54 } else { 54 } else {
55 - $this->error(__('发送失败,请检查短信配置是否正确')); 55 + $this->error($ret['msg']);
56 } 56 }
57 } 57 }
58 58
59 public function getCode($mobile, $code = null, $event = 'default'){ 59 public function getCode($mobile, $code = null, $event = 'default'){
60 $code = is_null($code) ? mt_rand(1000, 9999) : $code; 60 $code = is_null($code) ? mt_rand(1000, 9999) : $code;
61 $time = time(); 61 $time = time();
62 - $ip = request()->ip();  
63 - $sms = \app\common\model\Sms::create(['event' => $event, 'mobile' => $mobile, 'code' => $code, 'ip' => $ip, 'createtime' => $time]);  
64 - return $code; 62 + $sms = \app\common\model\Sms::create([
  63 + 'event' => $event,
  64 + 'mobile' => $mobile,
  65 + 'code' => $code,
  66 + 'ip' => request()->ip(),
  67 + 'createtime' => $time
  68 + ]);
  69 + $ret = send_sms2([
  70 + 'content' => "【帛芮定制】您的验证码是:" . $code . ",请尽快返回完成验证,请勿转载或泄露,谨防被骗。",//短信内容
  71 + 'mobile' => $mobile,//手机号码
  72 + 'tKey' => time(),
  73 + ]);
  74 + $ret = json_decode($ret,true);
  75 + if($ret['code'] == 200){
  76 + return true;
  77 + }
  78 + $this->error($ret['msg']);
65 } 79 }
66 80
67 /** 81 /**
@@ -92,4 +106,30 @@ class Sms extends Api @@ -92,4 +106,30 @@ class Sms extends Api
92 return false; 106 return false;
93 } 107 }
94 } 108 }
  109 +
  110 + /**
  111 + * post提交数据
  112 + */
  113 + protected function httpPost($url, $date) { // 模拟提交数据函数
  114 + $curl = curl_init(); // 启动一个CURL会话
  115 + curl_setopt($curl, CURLOPT_URL, $url); // 要访问的地址
  116 + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
  117 + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
  118 + curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
  119 + curl_setopt($curl, CURLOPT_POST, true); // 发送一个常规的Post请求
  120 + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($date)); // Post提交的数据包
  121 + curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
  122 + curl_setopt($curl, CURLOPT_HEADER, false); // 显示返回的Header区域内容
  123 + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回
  124 + curl_setopt($curl, CURLOPT_HEADER, true); //开启header
  125 + curl_setopt($curl, CURLOPT_HTTPHEADER, array(
  126 + 'Content-Type: application/json; charset=utf-8'
  127 + )); //类型为json
  128 + $result = curl_exec($curl); // 执行操作
  129 + if (curl_errno($curl)) {
  130 + echo 'Error POST' . curl_error($curl);
  131 + }
  132 + curl_close($curl); // 关键CURL会话
  133 + return $result; // 返回数据
  134 + }
95 } 135 }
@@ -425,3 +425,17 @@ if (!function_exists('guidv4')) { @@ -425,3 +425,17 @@ if (!function_exists('guidv4')) {
425 return $guidv4; 425 return $guidv4;
426 } 426 }
427 } 427 }
  428 +
  429 +if(!function_exists('send_sms2')) {
  430 + function send_sms2($data){
  431 + //todo 短信账号密码
  432 + require_once EXTEND_PATH . 'nsms/nsms2.php';
  433 + $url = "https://api.mix2.zthysms.com/v2/sendSms";
  434 + $username = config('site.sms_username');
  435 + $password = config('site.sms_password');
  436 + $sendAPI = new \sendAPI($url, $username, $password);
  437 + $sendAPI->data = $data;/*初始化数据包*/
  438 + $return = $sendAPI->sendSMS('POST');
  439 + return $return;
  440 + }
  441 +}
@@ -255,7 +255,7 @@ class Cart extends Model @@ -255,7 +255,7 @@ class Cart extends Model
255 } 255 }
256 }else{ 256 }else{
257 if(count($coupon['list']) > 0 && $coupon['list'][0]['isusable'] == '1'){ 257 if(count($coupon['list']) > 0 && $coupon['list'][0]['isusable'] == '1'){
258 - $coupon['user_coupon_id'] = $coupon['list'][0]['coupon']['id']; 258 + $coupon['user_coupon_id'] = $coupon['list'][0]['id'];
259 $coupon['coupon_name'] = $coupon['list'][0]['coupon']['coupon_name']; 259 $coupon['coupon_name'] = $coupon['list'][0]['coupon']['coupon_name'];
260 $coupon['coupon_price'] = $coupon['list'][0]['coupon']['coupon_price']; 260 $coupon['coupon_price'] = $coupon['list'][0]['coupon']['coupon_price'];
261 } 261 }
@@ -6,6 +6,12 @@ use think\Model; @@ -6,6 +6,12 @@ use think\Model;
6 6
7 class UserCoupon extends Model 7 class UserCoupon extends Model
8 { 8 {
  9 + // 开启自动写入时间戳字段
  10 + protected $autoWriteTimestamp = 'int';
  11 + // 定义时间戳字段名
  12 + protected $createTime = 'createtime';
  13 + protected $updateTime = 'updatetime';
  14 +
9 /** 15 /**
10 * 优惠券 16 * 优惠券
11 */ 17 */
@@ -24,7 +24,7 @@ return array ( @@ -24,7 +24,7 @@ return array (
24 'dictionary' => 'Dictionary', 24 'dictionary' => 'Dictionary',
25 'wechat' => '小程序配置', 25 'wechat' => '小程序配置',
26 'silk' => '织帛配置', 26 'silk' => '织帛配置',
27 - 'example' => 'Example', 27 + 'sms' => '短信配置',
28 ), 28 ),
29 'mail_type' => '1', 29 'mail_type' => '1',
30 'mail_smtp_host' => 'smtp.qq.com', 30 'mail_smtp_host' => 'smtp.qq.com',
@@ -57,4 +57,6 @@ return array ( @@ -57,4 +57,6 @@ return array (
57 'member_intro' => '<h1 class="firstTitle" style="padding: 0px; margin-top: 0.24rem; margin-bottom: 0.16rem; list-style: none; font-family: 微软雅黑, Arial; font-weight: 600; font-size: 0.22rem; color: rgb(0, 0, 0); line-height: 0.22rem; text-align: justify;"><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;会员级别共分四个等级,具体为:普通会员、铜牌会员、银牌会员、金牌会员,级别升降由动品网客服操作来实现。</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;"><br>一、 普通会员</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;"><img src="http://www.dpin100.com/images/upload/Image/rank_0(1).gif" width="58" height="58" align="middle" alt="" style="margin: 0px; padding: 0px; border-width: initial; border-style: none; list-style-type: none;">&nbsp;&nbsp;申请条件:任何人都可以免费注册成为动品网的普通会员 。</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">二、铜牌会员</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;"><img src="http://www.dpin100.com/images/upload/Image/rank_12(1).gif" width="60" height="60" align="middle" alt="" style="margin: 0px; padding: 0px; border-width: initial; border-style: none; list-style-type: none;">&nbsp; &nbsp;申请条件:一年内 一次性购买超过1000元或一年内累计购物超过2000元</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">特权:不定期为铜牌会员推出的特价活动</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;"><br>三、 银牌会员&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;"><img src="http://www.dpin100.com/images/upload/Image/rank_13.gif" width="60" height="60" align="middle" alt="" style="margin: 0px; padding: 0px; border-width: initial; border-style: none; list-style-type: none;">&nbsp;&nbsp;申请条件:一年内一次性购买超过2000元或一年内累计购物超过3000元</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;"><br>特权:<br>1、成为银牌会员&nbsp;一年内提供2次免邮费活动(限普通快递,顺丰和货到付款,特价商品等除外)<br>2、不定期为银牌会员推出的特价活动</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">四、 金牌会员</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;<img src="http://www.dpin100.com/images/upload/Image/rank_14(1).gif" width="60" height="60" align="middle" alt="" style="margin: 0px; padding: 0px; border-width: initial; border-style: none; list-style-type: none;">申请条件: 一年内一次性购买超过3000元或一年内累计购物超过5000元&nbsp;<br>&nbsp;<br>特权:<br>1、成为金牌会员一年内提供5次免邮费活动&nbsp;(限普通快递,顺丰和货到付款,特价商品等除外)<br>2、不定期为金牌会员推出的特价活动</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">注:<br>1、订单完成后需要一周时间完成会员升级或直接联系客服进行升级。<br>2、动品网可以在没有特殊通知的情况下自行变更本条款,并以网站公示为准。</p></h1>', 57 'member_intro' => '<h1 class="firstTitle" style="padding: 0px; margin-top: 0.24rem; margin-bottom: 0.16rem; list-style: none; font-family: 微软雅黑, Arial; font-weight: 600; font-size: 0.22rem; color: rgb(0, 0, 0); line-height: 0.22rem; text-align: justify;"><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;会员级别共分四个等级,具体为:普通会员、铜牌会员、银牌会员、金牌会员,级别升降由动品网客服操作来实现。</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;"><br>一、 普通会员</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;"><img src="http://www.dpin100.com/images/upload/Image/rank_0(1).gif" width="58" height="58" align="middle" alt="" style="margin: 0px; padding: 0px; border-width: initial; border-style: none; list-style-type: none;">&nbsp;&nbsp;申请条件:任何人都可以免费注册成为动品网的普通会员 。</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">二、铜牌会员</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;"><img src="http://www.dpin100.com/images/upload/Image/rank_12(1).gif" width="60" height="60" align="middle" alt="" style="margin: 0px; padding: 0px; border-width: initial; border-style: none; list-style-type: none;">&nbsp; &nbsp;申请条件:一年内 一次性购买超过1000元或一年内累计购物超过2000元</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">特权:不定期为铜牌会员推出的特价活动</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;"><br>三、 银牌会员&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;"><img src="http://www.dpin100.com/images/upload/Image/rank_13.gif" width="60" height="60" align="middle" alt="" style="margin: 0px; padding: 0px; border-width: initial; border-style: none; list-style-type: none;">&nbsp;&nbsp;申请条件:一年内一次性购买超过2000元或一年内累计购物超过3000元</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;"><br>特权:<br>1、成为银牌会员&nbsp;一年内提供2次免邮费活动(限普通快递,顺丰和货到付款,特价商品等除外)<br>2、不定期为银牌会员推出的特价活动</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">四、 金牌会员</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;<img src="http://www.dpin100.com/images/upload/Image/rank_14(1).gif" width="60" height="60" align="middle" alt="" style="margin: 0px; padding: 0px; border-width: initial; border-style: none; list-style-type: none;">申请条件: 一年内一次性购买超过3000元或一年内累计购物超过5000元&nbsp;<br>&nbsp;<br>特权:<br>1、成为金牌会员一年内提供5次免邮费活动&nbsp;(限普通快递,顺丰和货到付款,特价商品等除外)<br>2、不定期为金牌会员推出的特价活动</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">&nbsp;</p><p style="margin-bottom: 0px; padding: 0px; border: none; list-style-type: none; line-height: 25px; color: rgb(64, 64, 64); font-family: ΢ź, Verdana, Arial; font-size: 15px; font-weight: 400; text-align: left;">注:<br>1、订单完成后需要一周时间完成会员升级或直接联系客服进行升级。<br>2、动品网可以在没有特殊通知的情况下自行变更本条款,并以网站公示为准。</p></h1>',
58 'return_goods_reason' => '收到商品损坏了 58 'return_goods_reason' => '收到商品损坏了
59 商品与描述不符', 59 商品与描述不符',
  60 + 'sms_username' => 'zhibo123',
  61 + 'sms_password' => 'cxz307311',
60 ); 62 );
  1 +<?php
  2 +date_default_timezone_set('PRC');//设置时区
  3 +/**
  4 + * 发送API
  5 + * demo仅供参考,demo最低运行环境PHP5.3
  6 + * 请确认开启PHP CURL 扩展
  7 + */
  8 +class sendAPI {
  9 + public $data; //发送数据
  10 + public $timeout = 30; //超时
  11 + private $apiUrl; //发送地址
  12 + private $username; //用户名
  13 + private $password; //密码
  14 +
  15 + function __construct($url, $username, $password) {
  16 + $this->apiUrl = $url;
  17 + $this->username = $username;
  18 + $this->password = $password;
  19 + }
  20 +
  21 + private function httpGet() {
  22 + $url = $this->apiUrl . '?' . http_build_query($this->data);
  23 + $curl = curl_init();
  24 + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  25 + curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout);
  26 + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  27 + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  28 + curl_setopt($curl, CURLOPT_URL, $url);
  29 + $res = curl_exec($curl);
  30 + if (curl_errno($curl)) {
  31 + echo 'Error GET '.curl_error($curl);
  32 + }
  33 + curl_close($curl);
  34 + return $res;
  35 + }
  36 +
  37 + private function httpPost(){ // 模拟提交数据函数
  38 + $curl = curl_init(); // 启动一个CURL会话
  39 + curl_setopt($curl, CURLOPT_URL, $this->apiUrl); // 要访问的地址
  40 + curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); // 对认证证书来源的检查
  41 + curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); // 从证书中检查SSL加密算法是否存在
  42 + curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
  43 + curl_setopt($curl, CURLOPT_POST, true); // 发送一个常规的Post请求
  44 + curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($this->data)); // Post提交的数据包
  45 + curl_setopt($curl, CURLOPT_TIMEOUT, 30); // 设置超时限制防止死循环
  46 + curl_setopt($curl, CURLOPT_HEADER, false); // 显示返回的Header区域内容
  47 + curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回
  48 + curl_setopt($curl, CURLOPT_HEADER, false); //开启header
  49 + curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8')); //类型为json
  50 + $result = curl_exec($curl); // 执行操作
  51 + if (curl_errno($curl)) {
  52 + echo 'Error POST' . curl_error($curl);
  53 + }
  54 + curl_close($curl); // 关键CURL会话
  55 + return $result; // 返回数据
  56 + }
  57 +
  58 + /**
  59 + * @param $type|提交类型 POST/GET
  60 + * @param $isTranscoding|是否需要转 $isTranscoding 是否需要转utf-8 默认 false
  61 + * @return mixed
  62 + */
  63 + public function sendSMS($type, $isTranscoding = false) {
  64 + $this->data['content'] = $isTranscoding === true ? mb_convert_encoding($this->data['content'], "UTF-8") : $this->data['content'];
  65 + $this->data['username'] = $this->username;
  66 + $this->data['tKey'] = time();
  67 + $this->data['password'] = md5(md5($this->password) . $this->data['tKey']);
  68 +// dump($this->data);exit;
  69 + return $type == "POST" ? $this->httpPost() : $this->httpGet();
  70 + }
  71 +
  72 +}