Last active
March 10, 2020 04:23
-
-
Save alecguintu/de0a3750740b984af81b79ab6ce2ef95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
payload = { | |
"Request": { | |
"Product": { | |
"PrimaryCategory": "6614", | |
"Attributes": { | |
"name": "api create product test sample", | |
"short_description": "This is a nice product", | |
"brand": "Remark", | |
"model": "asdf", | |
"kid_years": "Kids (6-10yrs)" | |
}, | |
"Skus": { | |
"Sku": { | |
"SellerSku": "api-create-test-1", | |
"color_family": "Green", | |
"size": "40", | |
"quantity": "1", | |
"price": "388.50", | |
"package_length": "11", | |
"package_height": "22", | |
"package_weight": "33", | |
"package_width": "44", | |
"package_content": "this is what's in the box", | |
"Images": { | |
"Image": [ | |
"http://sg.s.alibaba.lzd.co/original/59046bec4d53e74f8ad38d19399205e6.jpg", | |
"http://sg.s.alibaba.lzd.co/original/179715d3de39a1918b19eec3279dd482.jpg" | |
] | |
} | |
} | |
} | |
} | |
} | |
} | |
access_token="50000700d329lnoworEdbKvkhRaUvgZDiu4rW1DjGth316a44c1ffztDCjgDH7P" | |
app_key="116891" | |
app_secret="CLsefCpRkTFFppZhKSvr0rsIAFt8dL35" | |
sign_methods="sha256" | |
timestamp="#{Date.today.to_time.to_i}" | |
parameters_str="/product/createaccess_token"+access_token+"app_key"+app_key+"sign_method"+sign_method+"timestamp"+timestamp | |
# => /product/createaccess_token50000700d329lnoworEdbKvkhRaUvgZDiu4rW1DjGth316a44c1ffztDCjgDH7Papp_key116891sign_methodsha256timestamp1583769600 | |
digest = OpenSSL::Digest.new(sign_methods) | |
sign=OpenSSL::HMAC.hexdigest(digest, app_secret, parameters_str) | |
# => 8cf966247e1926b6c48a16c18f605a5fcb4c644d13f978c03ec68697c538991b | |
request = LazopApiClient::Request.new('/product/create') | |
request.add_api_parameter("payload", payload.to_xml) | |
request.add_api_parameter("sign", sign) | |
response = @lazada.execute(request, access_token) | |
# => #<LazopApiClient::Response:0x007f8af97dfd58 @type="ISV", @code="IncompleteSignature", @message="The request signature does not conform to lazada standards", @body={"type"=>"ISV", "code"=>"IncompleteSignature", "message"=>"The request signature does not conform to lazada standards", "request_id"=>"0b0da12615838140378982088"}, @request_id="0b0da12615838140378982088"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment