Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wxh_internal_api
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
杨培培
wxh_internal_api
Commits
6e671fd1
Commit
6e671fd1
authored
Mar 18, 2019
by
杨培
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev-json-protocol'
parents
9d50e306
914cc968
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
Client.php
src/base/Client.php
+9
-8
No files found.
src/base/Client.php
View file @
6e671fd1
...
@@ -103,11 +103,13 @@ class Client
...
@@ -103,11 +103,13 @@ class Client
{
{
$instance
=
self
::
getInstance
();
$instance
=
self
::
getInstance
();
$url
=
$instance
->
apiUrl
.
(
strpos
(
$instance
->
apiUrl
,
'?'
)
!==
false
?
'&'
:
'?'
)
.
'api='
.
urlencode
(
$api
);
$requestBody
=
is_array
(
$params
)
?
json_encode
(
$params
,
JSON_UNESCAPED_UNICODE
)
:
''
;
list
(
$sign
,
$timestamp
,
$nonce
)
=
$instance
->
signature
(
$api
,
$params
);
list
(
$sign
,
$timestamp
,
$nonce
)
=
$instance
->
signature
(
$api
,
$requestBody
);
$url
.=
"&client_id=
{
$instance
->
clientId
}
&sign=
{
$sign
}
×tamp=
{
$timestamp
}
&nonce=
{
$nonce
}
"
;
$url
=
$instance
->
apiUrl
.
(
strpos
(
$instance
->
apiUrl
,
'?'
)
!==
false
?
'&'
:
'?'
)
.
'api='
.
urlencode
(
$api
)
.
"&client_id=
{
$instance
->
clientId
}
&sign=
{
$sign
}
×tamp=
{
$timestamp
}
&nonce=
{
$nonce
}
"
;
list
(
$httpCode
,
$response
)
=
$instance
->
request
(
$url
,
$params
);
list
(
$httpCode
,
$response
)
=
$instance
->
request
(
$url
,
$requestBody
,
$requestBody
?
[
'Content-Type: application/json'
]
:
[]);
if
(
$httpCode
==
200
&&
$response
!==
false
)
{
if
(
$httpCode
==
200
&&
$response
!==
false
)
{
$data
=
@
json_decode
(
$response
,
true
);
$data
=
@
json_decode
(
$response
,
true
);
...
@@ -139,15 +141,14 @@ class Client
...
@@ -139,15 +141,14 @@ class Client
* 对请求进程签名
* 对请求进程签名
*
*
* @param string $api
* @param string $api
* @param
array $params
* @param
string $pstr
* @return array
* @return array
*/
*/
protected
function
signature
(
$api
,
$p
arams
)
protected
function
signature
(
$api
,
$p
str
)
{
{
$timestamp
=
time
();
$timestamp
=
time
();
$nonce
=
uniqid
();
$nonce
=
uniqid
();
ksort
(
$params
);
$str
=
$api
.
$pstr
.
$this
->
clientId
.
$this
->
clientSecret
.
$timestamp
.
$nonce
;
$str
=
$api
.
http_build_query
(
$params
)
.
$this
->
clientId
.
$this
->
clientSecret
.
$timestamp
.
$nonce
;
$sign
=
md5
(
$str
);
$sign
=
md5
(
$str
);
return
[
$sign
,
$timestamp
,
$nonce
];
return
[
$sign
,
$timestamp
,
$nonce
];
...
...
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