Let’s take RegUserInfo as an example.
Encryption requires the following parameters
- method (String, “RegUserInfo”)
- Key (String, the Secret Key)
- Time (DateTime, Current Time, in yyyyMMddHHmmss format)
- Username (String)
- CurrencyType (String)
method, Key and Time are always inserted. Other parameters please follow the parameter list in each API function.
Let say, the Secret Key is XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX and md5key is YYYYYYYY.
Example Query String (QS):
1 2 3 |
QS = “method=RegUserInfo&Key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&Time=20140101123456&Username=DemoUser001&CurrencyType=USD”; q = HttpUtility.UrlEncode( DESencrypt(QS) ); |
For example, q = ‘j4tjorjwarfj3trwise0safrwg2wt4awari0fwjfeoh’
Example MD5 String for building the signature (QS + md5key + Time + Key):
1 |
s = BuildMD5(QS + “YYYYYYYY” + “20140101123456” + “XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”); |
For example, s = ‘1234567890abcdef’
Resulting POST method query (using “Content-Type: application/x-www-form-urlencoded”):
q=j4tjorjwarfj3trwise0safrwg2wt4awari0fwjfeoh&s=1234567890abcdef
POST to: http://<api-domain>/api/api.aspx
Output
1 2 3 4 5 6 |
<?xml version="1.0" encoding="utf-8"?> <RegUserInfoResponse xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Username>DemoUser001</Username> <ErrorMsgId>0</ErrorMsgId> <ErrorMsg>Success</ErrorMsg> </RegUserInfoResponse> |