多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ###途牛签名流程 1. 将入参按照一级key值进行排序,去掉value值为空的入参,我们将得到以下格式参数+系统参数)如下 ` { "agencyProductId":"test10001", "apiKey":"testApiKey", "planInfo":[{ "planDateStr":"2015-07-18", "datePriceList":[{ "schemeId":"scheme0001", "scheduleId":"schedule", "agencyBudget":1000, "agencyBudgetChild":500, "excludeChild":1, "roomAddBudget":100, "roomGapFlag":1, "aheaddate":4, "deadlinedate":3, "deadlinehour":18, "promoFlag":1, "setGroupFlag":1, "stuffEndDate":5 }] }], "timestamp":"2015-07-30 12:34:56" } ` 2. 将排序好的入参依次拼接起来,如下: ` agencyProductIdtest10001apiKeytestApiKeyplanInfo[{"planDateStr":"2015-07-18","datePriceList":[{"schemeId":"scheme0001","scheduleId":"schedule","agencyBudget":1000,"agencyBudgetChild":500,"excludeChild":1,"roomAddBudget":100,"roomGapFlag":1,"aheaddate":4,"deadlinedate":3,"deadlinehour":18,"promoFlag":1,"setGroupFlag":1,"stuffEndDate":5}]}]timestamp2015-07-30 12:34:56` 3. 在拼好的字符串前后都加上签名密钥,我们假设密钥是ZbWjUMYevqT9Tnup4jRs,可以得到以下字符串: `ZbWjUMYevqT9Tnup4jRsagencyProductIdtest10001apiKeytestApiKeyplanInfo[{"planDateStr":"2015-07-18","datePriceList":[{"schemeId":"scheme0001","scheduleId":"schedule","agencyBudget":1000,"agencyBudgetChild":500,"excludeChild":1,"roomAddBudget":100,"roomGapFlag":1,"aheaddate":4,"deadlinedate":3,"deadlinehour":18,"promoFlag":1,"setGroupFlag":1,"stuffEndDate":5}]}]timestamp2015-07-30 12:34:56ZbWjUMYevqT9Tnup4jRs` 4. 对生成的字符串进行MD5加密,并将结果全部转为大写,获得签名值: `E30F44C19525EFD997BB8791421C3206` 5. 将签名加入到入参中: ` { "agencyProductId":"test10001", "apiKey":"testApiKey", "planInfo":[{ "planDateStr":"2015-07-18", "datePriceList":[{ "schemeId":"scheme0001", "scheduleId":"schedule", "agencyBudget":1000, "agencyBudgetChild":500, "excludeChild":1, "roomAddBudget":100, "roomGapFlag":1, "aheaddate":4, "deadlinedate":3, "deadlinehour":18, "promoFlag":1, "setGroupFlag":1, "stuffEndDate":5 }] }], "timestamp":"2015-07-30 12:34:56", "sign":"E30F44C19525EFD997BB8791421C3206" } ` 6.发起HTTP请求。