Dunhuang net open platform API, as long as the user in accordance with API specification assembled a correct URL, HTTP request to the platform, users will be able to get the data they need. Schematic diagram of the call is as follows (Note: Dunhuang network API
Environment address, that call interface (API), through access to the address, to get the interface need to get data
Formal environment: http: //api.dhgate.com/dop/router
Sandbox environment: http: //sandbox.api.dhgate.com/dop/router
Sandbox test environment - help can refer to application environments introduce
call API, you must pass system and application parameters. System parameters detailed below; application API their different due to the different parameters, where to dh.product.get (for product information) as an example, please refer to more API documentation
1) system parameters
| parameter name | Type | Required | Introduction |
| method | string | true | API interface names, refer to the API documentation corresponding interface name, dh.product.get |
| v | string | true | interface version number, refer to the API documentation corresponding interface version number |
| access_token | string | true | request token, you need to obtain advance authorization interface via OAuth2 Token |
| parameter name | Type | Required | Introduction |
| itemcode | string | true | Product Code ITEMCODE |
| parameter name | Type | Required | Introduction |
| product | ProductVO | true | product information, product information is returned in JSON format |
invocation API: Get product information dh.product.get , application parameters commodity code itemcode, return parameter product is returned in JSON format product information.
1) Get access_token:to [use the user name and password to obtain Access Token, suitable for any type of application] way to get access_token, username and password to log seller platform (sandbox sandbox environment requires a user name and password, online you need to line real user name and password) username and password, the request url as follows:
http://sandbox.api.dhgate.com/dop/oauth2/access_token?grant_type=password&username=gynnx&password=1qaz2wsx&client_id=NwogzOA82SHK1DY8u57i&client_secret=MCIcgXX2HWbQQ5NV8Vf5sjvjJj4Df0D8&scope=basic
returns the contents as follows:
{"expires_in": 1378545787369, "scope": "basic", "refresh_token": "8XDK2qYzU1UgowIZGoVJrwNGLEpS97AzpVwvBXXc", "access_token": "VSmvRqLB5qbSZqKFMrU6IRBZYQSHCweyt16aqN8B"}
2) Input parameters:
method = dh.product.get
v = 1.0
access_token = VSmvRqLB5qbSZqKFMrU6IRBZYQSHCweyt16aqN8B
itemcode = 999224210
3) Assembling HTTP request:
converts all parameter values for the UTF-8 encoding, and then assembled, access the address via a browser interface that successfully called once, as follows: http://sandbox.api.dhgate.com/dop/router?method=dh.product.get&v=1.0&access_token=VSmvRqLB5qbSZqKFMrU6IRBZYQSHCweyt16aqN8B&itemcode=999224210
1) All requests and responses are all data encoding utf-8 format, characters and special characters in the url to do urlencode encoding.
2) access to information query class API recommended get requests, transaction and other private information query and modify classes API recommended post requests.
3) dh.user.seller.get sellers to obtain user information interface that returns the seller ID, some interfaces need supplierId parameters, you can get through this interface, it is recommended to do supplierId seller ID information stored locally, not every request API acquisition.
4) sandbox test environment, consistent application appkey, appsecet information online environment sandbox environment with no need to repeat the application, just different permissions.
5) Modify the class interfaces generally do not support the get method request, unified post way request.
6) oauth2 protocol to determine the application of information through access_token, so please keep access_token, refresh_token avoid leakage.
7) the need to advance through oauth2 interface to obtain access_token information [seller developers can use the user name and password to obtain Access Token, suitable for any type of application] way to get access_token information.
8) access_token currently valid for one day, one day you can continue to use, you can use after expiration [way] Refresh_Token get Access_Token retrieve access_token.
java examples will be provided later