Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qmai-openapi-sign-util
Project
Project
Details
Activity
Releases
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
王敬磊
qmai-openapi-sign-util
Commits
8bf4a9dc
Commit
8bf4a9dc
authored
Apr 07, 2023
by
王敬磊
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加token参数校验方法及示例
parent
a0b30aaf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
28 deletions
+10
-28
GenerateTokenExample.java
...a/com/qmai/openapi/sign/example/GenerateTokenExample.java
+10
-28
No files found.
src/main/java/com/qmai/openapi/sign/example/GenerateTokenExample.java
View file @
8bf4a9dc
...
...
@@ -14,8 +14,6 @@ import org.apache.http.util.EntityUtils;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* 类描述: token生成及接口请求示例
...
...
@@ -43,42 +41,26 @@ public class GenerateTokenExample {
public
static
void
main
(
String
[]
args
)
{
String
url
=
"https://openapi.qmai.co/v3/baking/customer/userRecharge"
;
String
token
=
QmaiTokenUtil
.
getToken
(
grantCode
,
openId
,
openKey
,
nonce
,
timestamp
);
BaseOuterOpenapiRequest
<
JSONObject
>
request
=
new
BaseOuterOpenapiRequest
<>();
request
.
setNonce
(
nonce
);
request
.
setToken
(
token
);
Map
<
String
,
Object
>
requestParam
=
new
HashMap
<>();
requestParam
.
put
(
"openId"
,
openId
);
requestParam
.
put
(
"grantCode"
,
grantCode
);
request
.
setToken
(
token
);
request
.
setNonce
(
nonce
);
request
.
setOpenId
(
openId
);
request
.
setGrantCode
(
grantCode
);
request
.
setTimestamp
(
timestamp
);
// 业务参数 content
HashMap
<
String
,
Object
>
bizParam
=
new
HashMap
<>();
bizParam
.
put
(
"shopCode"
,
18
);
bizParam
.
put
(
"activityId"
,
"785425500976746497"
);
bizParam
.
put
(
"amount"
,
300
);
bizParam
.
put
(
"giveAmount"
,
20
);
bizParam
.
put
(
"bizId"
,
"2102819060916404224"
);
bizParam
.
put
(
"source"
,
"8"
);
HashMap
<
String
,
Object
>
customerCodeType
=
new
HashMap
<>();
customerCodeType
.
put
(
"customerCode"
,
"778770795093545867"
);
customerCodeType
.
put
(
"type"
,
"9"
);
bizParam
.
put
(
"customerCodeType"
,
customerCodeType
);
bizParam
.
put
(
"remarks"
,
""
);
requestParam
.
put
(
"params"
,
bizParam
);
requestParam
.
put
(
"nonce"
,
nonce
);
requestParam
.
put
(
"timestamp"
,
timestamp
);
requestParam
.
put
(
"token"
,
token
);
String
response
=
doPost
(
url
,
requestParam
);
JSONObject
bizParam
=
new
JSONObject
();
request
.
setParams
(
bizParam
);
String
response
=
doPost
(
url
,
request
);
System
.
out
.
println
(
response
);
}
public
static
String
doPost
(
String
url
,
Map
<
String
,
Object
>
param
)
{
public
static
String
doPost
(
String
url
,
BaseOuterOpenapiRequest
<
JSON
Object
>
param
)
{
CloseableHttpClient
httpClient
=
HttpClientBuilder
.
create
().
build
();
try
{
if
(
httpClient
==
null
)
{
...
...
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