Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
browser-backend
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
browser-backend
Commits
e06f4648
Commit
e06f4648
authored
Jun 24, 2020
by
xuxin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/staging' into staging
parents
284e3a45
f3e3e47d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
SmsUtils.java
...va/com/edgec/browserbackend/account/service/SmsUtils.java
+7
-5
No files found.
src/main/java/com/edgec/browserbackend/account/service/SmsUtils.java
View file @
e06f4648
...
...
@@ -17,14 +17,15 @@ public class SmsUtils {
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
SmsUtils
.
class
);
private
static
final
int
TIME_OUT
=
10
*
60
;
//10minues
private
static
final
int
TIME_OUT
=
10
*
60
;
//10minues
/**
* Generate and send the SMS one time password to user's phone with SMS.
*
* @param phone
*/
public
static
String
sendSmsOTP
(
String
phone
)
{
String
randomCode
=
createRandom
(
true
,
6
);
String
randomCode
=
createRandom
(
true
,
6
);
DefaultProfile
profile
=
DefaultProfile
.
getProfile
(
"default"
,
"LTAIODPWRh6stFca"
,
"0SBDR59HsquSDEj9CFXNt9njTs2cCv"
);
IAcsClient
client
=
new
DefaultAcsClient
(
profile
);
...
...
@@ -37,19 +38,20 @@ public class SmsUtils {
request
.
putQueryParameter
(
"SignName"
,
"防关联浏览器"
);
request
.
putQueryParameter
(
"PhoneNumbers"
,
phone
);
request
.
putQueryParameter
(
"TemplateCode"
,
"SMS_185841618"
);
request
.
putQueryParameter
(
"TemplateParam"
,
"{\"code\":\""
+
randomCode
+
"\"}"
);
request
.
putQueryParameter
(
"TemplateParam"
,
"{\"code\":\""
+
randomCode
+
"\"}"
);
try
{
CommonResponse
response
=
client
.
getCommonResponse
(
request
);
if
(
response
.
getHttpStatus
()
==
200
&&
response
.
getData
().
contains
(
"OK"
))
{
return
randomCode
;
}
else
{
log
.
error
(
"fail to send sms {}"
,
response
.
getData
());
throw
new
ClientRequestException
(
AccountErrorCode
.
OTPSENDFAILS
,
AccountErrorCode
.
OTPSENDFAILS
.
getReason
());
}
}
catch
(
ServerException
e
)
{
log
.
error
(
"Sms sends failure"
,
e
);
log
.
error
(
"Sms sends failure"
,
e
);
throw
new
ClientRequestException
(
AccountErrorCode
.
OTPSENDFAILS
,
AccountErrorCode
.
OTPSENDFAILS
.
getReason
());
}
catch
(
ClientException
e
)
{
log
.
error
(
"Sms sends failure"
,
e
);
log
.
error
(
"Sms sends failure"
,
e
);
throw
new
ClientRequestException
(
AccountErrorCode
.
OTPSENDFAILS
,
AccountErrorCode
.
OTPSENDFAILS
.
getReason
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment