Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
蒋勇
zhichan
Commits
6e36415b
Commit
6e36415b
authored
Dec 05, 2019
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
d6c880ef
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
22 deletions
+23
-22
igirl-channel/app/base/api/impl/auth/jdAuth.js
+23
-22
No files found.
igirl-channel/app/base/api/impl/auth/jdAuth.js
View file @
6e36415b
...
@@ -19,10 +19,10 @@ class jdAuthAPI extends APIBase {
...
@@ -19,10 +19,10 @@ class jdAuthAPI extends APIBase {
}
}
async
getJdSign
(
pobj
,
qobj
,
req
)
{
async
getJdSign
(
pobj
,
qobj
,
req
)
{
try
{
try
{
const
{
Signer
,
Context
}
=
require
(
'../src'
)
let
ctx
=
new
Context
(
'x3k0s704lfun-test.cn-north-1.jdcloud-api.net'
,
'/market/order/
order-inner
/submit'
,
'POST'
,
null
,
'empty'
);
let
ctx
=
new
Context
(
'x3k0s704lfun-test.cn-north-1.jdcloud-api.net'
,
'/market/order/
api
/submit'
,
'POST'
,
null
,
'empty'
);
ctx
.
regionId
=
'cn-north-1'
ctx
.
regionId
=
'cn-north-1'
ctx
.
headers
.
set
(
'content-type'
,
'
text/plai
n'
)
ctx
.
headers
.
set
(
'content-type'
,
'
application/jso
n'
)
let
credentials
=
{
let
credentials
=
{
accessKeyId
:
'C6D680733C19362B5DF478207D6A90A4'
,
//替换自己的AK
accessKeyId
:
'C6D680733C19362B5DF478207D6A90A4'
,
//替换自己的AK
...
@@ -30,61 +30,62 @@ class jdAuthAPI extends APIBase {
...
@@ -30,61 +30,62 @@ class jdAuthAPI extends APIBase {
}
}
//测试报文:
//测试报文:
//GET
//ctx.body = "pin=jcloud_pRiHQTd&serviceId=580010&itemCode=FW_GOODS-580010-1&platform=6"
// ctx.body = "pin=jcloud_pRiHQTd&serviceId=580010&itemCode=FW_GOODS-580010-1&platform=6"
//POST
//POST
var
qs
=
require
(
'querystring'
);
var
qs
=
require
(
'querystring'
);
var
post_data
=
{
pin
=
"jcloud_pRiHQTd"
,
serviceId
=
580010
,
itemCode
=
"FW_GOODS-580010-1"
,
platform
=
6
};
//这是需要提交的数据
var
post_data
=
{
pin
:
"syaify"
,
serviceId
:
580010
,
itemCode
:
"FW_GOODS-580010-1"
,
platform
:
6
,
orderNum
:
1
,
articleType
:
1
};
//这是需要提交的数据
var
tmpContent
=
JSON
.
stringify
(
post_data
);
var
tmpContent
=
JSON
.
stringify
(
post_data
);
var
tmpContentLength
=
Buffer
.
byteLength
(
tmpContent
);
var
content
=
qs
.
stringify
(
post_data
);
var
content
=
qs
.
stringify
(
post_data
);
ctx
.
body
=
content
;
ctx
.
body
=
tmpContent
;
ctx
.
method
=
'POST'
ctx
.
method
=
'POST'
var
signer
=
new
Signer
(
ctx
,
credentials
)
signer
=
new
Signer
(
ctx
,
credentials
);
var
dd
=
new
Date
()
ctx
.
headers
.
set
(
'Content-Length'
,
ctx
.
body
.
length
)
ctx
.
buildNonce
()
var
auth
=
signer
.
sign
(
dd
);
ctx
.
headers
.
set
(
'Content-Length'
,
tmpContentLength
)
ctx
.
buildNonce
()
var
dd
=
new
Date
();
var
auth
=
signer
.
sign
(
dd
)
console
.
log
(
"POST签名为:"
,
auth
)
console
.
log
(
"POST签名为:"
,
auth
)
ctx
.
headers
.
set
(
'Authorization'
,
auth
)
ctx
.
headers
.
set
(
'Authorization'
,
auth
)
////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
var
http
=
require
(
'https'
);
var
http
=
require
(
'https'
);
// var content = ctx.body;
var
options
=
{
var
options
=
{
host
:
'x3k0s704lfun-test.cn-north-1.jdcloud-api.net'
,
host
:
'x3k0s704lfun-test.cn-north-1.jdcloud-api.net'
,
port
:
443
,
port
:
443
,
path
:
'/market/order/
order-inner
/submit'
,
path
:
'/market/order/
api
/submit'
,
method
:
'POST'
,
method
:
'POST'
,
headers
:
{
headers
:
{
}
}
};
};
for
(
let
[
key
,
value
]
of
ctx
.
headers
)
{
for
(
let
[
key
,
value
]
of
ctx
.
headers
)
{
options
.
headers
[
key
]
=
value
options
.
headers
[
key
]
=
value
}
}
console
.
log
(
"post options:
\
n"
,
options
);
console
.
log
(
"
\
n post options:
\
n"
,
options
);
//console.log("content:",content);
console
.
log
(
"
\
n tmpContent:
\
n"
,
tmpContent
);
//console.log("\n");
var
req
=
http
.
request
(
options
,
function
(
res
)
{
var
req
=
http
.
request
(
options
,
function
(
res
)
{
console
.
log
(
"
--jd>>>>>>>>>>>>>
statusCode: "
,
res
.
statusCode
);
console
.
log
(
"statusCode: "
,
res
.
statusCode
);
console
.
log
(
"
--jd>>>>>>>>>>>>>
headers: "
,
res
.
headers
);
console
.
log
(
"headers: "
,
res
.
headers
);
var
_data
=
''
;
var
_data
=
''
;
res
.
on
(
'data'
,
function
(
chunk
)
{
res
.
on
(
'data'
,
function
(
chunk
)
{
_data
+=
chunk
;
_data
+=
chunk
;
});
});
res
.
on
(
'end'
,
function
()
{
res
.
on
(
'end'
,
function
()
{
console
.
log
(
"
\
n---
jd>>>>>>>>>>>>>.
>>
\
nresult:"
,
_data
)
console
.
log
(
"
\
n--->>
\
nresult:"
,
_data
)
});
});
});
});
req
.
on
(
'error'
,
(
e
)
=>
{
req
.
on
(
'error'
,
(
e
)
=>
{
console
.
error
(
`
--jd>>>>>>>>>>>>>请求遇到问题
:
${
e
.
message
}
`
);
console
.
error
(
`
请求遇到问题-------------
:
${
e
.
message
}
`
);
});
});
req
.
write
(
c
ontent
);
req
.
write
(
tmpC
ontent
);
req
.
end
();
req
.
end
();
}
catch
(
errorMsg
)
{
}
catch
(
errorMsg
)
{
console
.
log
(
errorMsg
,
"--jd>>>>>>>errorMsg..............................>>>>>>"
);
console
.
log
(
errorMsg
,
"--jd>>>>>>>errorMsg..............................>>>>>>"
);
}
}
...
...
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