切换导航条
此项目
正在载入...
登录
潘浩文
/
scoreshop
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
潘浩文
6 years ago
提交
0e2c75c062a247890aae94020abf8d001271d885
1 个父辈
51957217
1 个管道 的构建
通过
耗费 0 秒
1
变更
2
构建
1
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
50 行增加
和
34 行删除
app/portal/service/MobileService.php
app/user/controller/RegisterController.php
app/portal/service/MobileService.php
查看文件 @
0e2c75c
...
...
@@ -10,38 +10,54 @@ class MobileService{
/**
* 百荣科技短信通知接口
*/
public
function
sendSMSS
(
$mobile
,
$content
){
date_default_timezone_set
(
'PRC'
);
//设置时区
$url
=
"http://www.ztsms.cn/sendNSms.do"
;
//提交地址
$username
=
'nonyegongzhonghao'
;
//用户名
$password
=
'Cxz307312'
;
//原密码
$mobile
=
$mobile
;
$data
=
array
(
'content'
=>
"您的验证码是"
.
$content
.
"有效期1分钟,请及时使用"
.
"【金智农】"
,
//短信内容
'mobile'
=>
$mobile
,
//手机号码
'productid'
=>
'887361'
,
//产品id
'xh'
=>
''
//小号
);
$isTranscoding
=
false
;
$timeout
=
30
;
$data
[
'content'
]
=
$isTranscoding
===
true
?
mb_convert_encoding
(
$data
[
'content'
],
"UTF-8"
)
:
$data
[
'content'
];
$data
[
'username'
]
=
$username
;
$data
[
'tkey'
]
=
date
(
'YmdHis'
);
$data
[
'password'
]
=
md5
(
md5
(
$password
)
.
$data
[
'tkey'
]);
$curl
=
curl_init
();
// 启动一个CURL会话
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
// 要访问的地址
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYPEER
,
false
);
// 对认证证书来源的检查
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYHOST
,
false
);
// 从证书中检查SSL加密算法是否存在
curl_setopt
(
$curl
,
CURLOPT_USERAGENT
,
$_SERVER
[
'HTTP_USER_AGENT'
]);
// 模拟用户使用的浏览器
curl_setopt
(
$curl
,
CURLOPT_POST
,
true
);
// 发送一个常规的Post请求
curl_setopt
(
$curl
,
CURLOPT_POSTFIELDS
,
http_build_query
(
$data
));
// Post提交的数据包
curl_setopt
(
$curl
,
CURLOPT_TIMEOUT
,
$timeout
);
// 设置超时限制防止死循环
curl_setopt
(
$curl
,
CURLOPT_HEADER
,
false
);
// 显示返回的Header区域内容
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
true
);
// 获取的信息以文件流的形式返回
$result
=
curl_exec
(
$curl
);
// 执行操作
if
(
curl_errno
(
$curl
)){
echo
'Error POST'
.
curl_error
(
$curl
);
function
sendTemplateSMS
(
$to
,
$datas
,
$tempId
)
{
include_once
(
"./CCPRestSmsSDK.php"
);
// 初始化REST SDK
//主帐号,对应开官网发者主账号下的 ACCOUNT SID
$accountSid
=
'13821821000'
;
//主帐号令牌,对应官网开发者主账号下的 AUTH TOKEN
$accountToken
=
'suntata12345'
;
//应用Id,在官网应用列表中点击应用,对应应用详情中的APP ID
//在开发调试的时候,可以使用官网自动为您分配的测试Demo的APP ID
$appId
=
''
;
//请求地址
//沙盒环境(用于应用开发调试):sandboxapp.cloopen.com
//生产环境(用户应用上线使用):app.cloopen.com
$serverIP
=
'app.cloopen.com'
;
//请求端口,生产环境和沙盒环境一致
$serverPort
=
'8883'
;
//REST版本号,在官网文档REST介绍中获得。
$softVersion
=
'2013-12-26'
;
$rest
=
new
REST
(
$serverIP
,
$serverPort
,
$softVersion
);
$rest
->
setAccount
(
$accountSid
,
$accountToken
);
$rest
->
setAppId
(
$appId
);
// 发送模板短信
$result
=
$rest
->
sendTemplateSMS
(
$to
,
$datas
,
$tempId
);
if
(
$result
==
NULL
)
{
echo
"result error!"
;
return
2
;
}
if
(
$result
->
statusCode
!=
0
)
{
echo
"error code :"
.
$result
->
statusCode
.
"<br>"
;
echo
"error msg :"
.
$result
->
statusMsg
.
"<br>"
;
return
0
;
//TODO 添加错误处理逻辑
}
else
{
echo
"Sendind TemplateSMS success!<br/>"
;
// 获取返回信息
$smsmessage
=
$result
->
TemplateSMS
;
echo
"dateCreated:"
.
$smsmessage
->
dateCreated
.
"<br/>"
;
echo
"smsMessageSid:"
.
$smsmessage
->
smsMessageSid
.
"<br/>"
;
return
1
;
//TODO 添加成功处理逻辑
}
return
$result
;
}
}
\ No newline at end of file
...
...
app/user/controller/RegisterController.php
查看文件 @
0e2c75c
...
...
@@ -10,7 +10,7 @@
// +----------------------------------------------------------------------
namespace
app\user\controller
;
use
app\portal\service\Mobile
;
use
app\portal\service\Mobile
Service
;
use
cmf\controller\HomeBaseController
;
use
cmf\controller\WeChatBaseController
;
use
think\db
;
...
...
@@ -38,7 +38,7 @@ class RegisterController extends WeChatBaseController
$code
=
cmf_get_verification_code
(
$param
[
'mobile'
],
4
);
// var_dump($code);
if
(
$code
)
{
$mobile
=
new
Mobile
();
$mobile
=
new
();
$mobile
->
sendTemplateSMS
(
$param
[
'mobile'
],[
'code'
=>
$code
],
1
);
$re
=
cmf_verification_code_log
(
$param
[
'mobile'
],
$code
,
time
()
+
60
);
if
(
$re
){
...
...
请
注册
或
登录
后发表评论