阿狸子订单管理系统 是基于ThinkPHP开发的微信商城系统,是一款极简的PHP订单系统,支持货到付款,微信支付,非常不错,简介大方,适合做百度推广、联盟推广,高效快捷,后台功能齐全,小编今天就以替换短信接口为例带大家进行二次开发,我们使用的短信接口是我们短信宝短信群发平台的短信接口,我们短信宝短信群发平台非常稳定,发送速度快,注册就送测试短信,推荐大家使用
1:打开项目:\Public\Common\alizi.setting.php 在128行左右 增加短信端相关配置
1
2
3
4
5
6
7
|
'sms_setting' => array( 'sms_send' => array( 'name' => '短信发送' , 'options' =>array( '0' => '关闭' , '1' => '启用' ,), 'tags' => 'select' , 'decription' => '' , 'width' =>30, 'height' =>0, 'separator' =>0,), 'sms_admin' => array( 'name' => '通知对象' , 'value' =>1, 'options' =>array( '0' => '只通知客户' , '1' => '只通知管理员' , '2' => '同时通知管理员和客户' ,), 'tags' => 'select' , 'decription' => '' , 'width' =>35, 'height' =>0, 'separator' =>0,), 'sms_admin_mobile' => array( 'name' => '' , 'options' => '' , 'tags' => 'text' , 'decription' => '请填写管理员手机号,多个号码请用英文逗号隔开' , 'width' =>30, 'height' =>0, 'separator' =>0,), 'sms_account' => array( 'name' => '短信宝账号' , 'options' => '' , 'tags' => 'text' , 'decription' => '' , 'width' =>30, 'height' =>0, 'separator' =>0,), 'sms_password' => array( 'name' => '短信宝密码' , 'options' => '' , 'tags' => 'text' , 'decription' => '' , 'width' =>30, 'height' =>0, 'separator' =>0,), ), |
2:打开项目:\Home\Lib\Action\ApiAction.class.php 修改发送类函数
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
private function sendSMS($order_id){ if (empty($ this ->aliziConfig[ 'sms_send' ])){ return array( 'status' =>0); } $order = M( 'Order' )->where(array( 'id' =>$order_id))->find(); if (empty($order)) return array( 'status' =>0); $item = M( 'Item' )->where( 'id=' .$order[ 'item_id' ])->field( 'id,sms_send' )->find(); $sms = json_decode($item[ 'sms_send' ], true ); $status=$order[ 'status' ]; if ($sms[$status][ 'status' ]==1 && !empty($sms[$status][ 'content' ])){ //发送内容替换 $express = C( 'DELIVERY' ); $http_type = ((isset($_SERVER[ 'HTTPS' ]) && $_SERVER[ 'HTTPS' ] == 'on' ) || (isset($_SERVER[ 'HTTP_X_FORWARDED_PROTO' ]) && $_SERVER[ 'HTTP_X_FORWARDED_PROTO' ] == 'https' )) ? 'https://' : 'http://' ; $aliziHost = $http_type.$_SERVER[ 'HTTP_HOST' ].C( 'ALIZI_ROOT' ); $confirmUrl = $aliziHost.(C( 'URL_MODEL' )==2? 'a/' .$order[ 'order_no' ]: 'Api/confirm.php?id=' .$order[ 'order_no' ]); $mobiles = $order[ 'mobile' ]; if (!empty($ this ->aliziConfig[ 'sms_admin_mobile' ])){ switch ($ this ->aliziConfig[ 'sms_admin' ]) { case '1' : $mobiles = $ this ->aliziConfig[ 'sms_admin_mobile' ]; break ; case '2' : $mobiles .= ',' .$ this ->aliziConfig[ 'sms_admin_mobile' ]; break ; } } $replace = array( '{[AliziTitle]}' => $order[ 'item_name' ], '{[AliziParams]}' => $order[ 'item_params' ], '{[AliziName]}' => $order[ 'name' ], '{[AliziQuantity]}' => $order[ 'quantity' ], '{[AliziPrice]}' => $order[ 'total_price' ], '{[AliziExpress]}' => $express[$order[ 'delivery_name' ]], '{[AliziExpressNum]}' => $order[ 'delivery_no' ], '{[AliziConfirmUrl]}' => $confirmUrl, '#title#' => $order[ 'item_name' ], '#params#' => $order[ 'item_params' ], '#name#' => $order[ 'name' ], '#mobile#' => $order[ 'mobile' ], '#quantity#' => $order[ 'quantity' ], '#price#' => $order[ 'total_price' ], '#express#' => $express[$order[ 'delivery_name' ]], '#expressNum#' => $order[ 'delivery_no' ], '#confirmUrl#' => $confirmUrl, '#orderNum#' => $order[ 'order_no' ], ); $content = str_replace(array_keys($replace),array_values($replace),$sms[$status][ 'content' ]); $param[ 'u' ]=$ this ->aliziConfig[ 'sms_account' ]; $param[ 'p' ]=md5($ this ->aliziConfig[ 'sms_password' ]); $param[ 'm' ]=$order[ 'mobile' ]; $param[ 'c' ]= '【' .$ this ->aliziConfig[ 'title' ]. '】' .$content; $rs=file_get_contents($url.http_build_query($param)); if ($rs == "0" ){ $sendData = array( 'order_id' =>$order_id, 'order_status' =>$order[ 'status' ], 'mobile' =>$mobiles, 'sent_content' =>$content, 'sent_time' =>date( 'Y-m-d H:i:s' ), 'sent_status' =>1, ); M( 'Sent' )->add($sendData); } } } |
3:打开项目:\Admin\Lib\Action\IndexAction.class.php 修改查询余额类函数
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
public function smsBalance(){ header( 'Content-type: application/json' ); $aliziConfig = S( 'aliziConfig' ); if (empty($aliziConfig[ 'sms_account' ]) || empty($aliziConfig[ 'sms_password' ])){ $json = json_encode(array( 'status' =>0, 'data' =>0)); } else { $data = array( //'method'=>'balance', 'u' =>$aliziConfig[ 'sms_account' ], 'p' =>md5($aliziConfig[ 'sms_password' ]) //'url'=>"http://{$_SERVER['SERVER_NAME']}{$_SERVER['SCRIPT_NAME']}", ); $result=file_get_contents($url.http_build_query($data)); $result=explode( ',' ,$result); $json=json_encode(array( 'status' =>0, 'data' =>$result[1])); //$json = http( C('ALIZI_API').'/sms/', 'POST', $data ); } die($json); } |
经过上面的替换,短信宝的短信平台已经替换成功了,可以正常使用了。进行测试发送:
报备一下短信宝的VIP模板,这样就可以走短信宝的优质通道了,即便遇到敏感文字我们都不会人工审核,短信内容3~5秒就可送达。
另外:我们已经开发好完整的阿狸子V_2.9系统短信宝插件,点击此链接 下载及查看安装流程。
最新更新
电商类
CMS类
微信类