Service implement api or sdk of 3rd party.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
# service-3rd
|
|
|
|
|
|
|
|
Service implement api or sdk of 3rd party.
|
|
|
|
|
|
|
|
实现第三方平台接口的公用服务,通过API调用。
|
|
|
|
|
|
|
|
## 已对接功能
|
|
|
|
|
|
|
|
* 阿里云的短信发送接口
|
|
|
|
|
|
|
|
|
|
|
|
## 接口参数签名方法
|
|
|
|
|
|
|
|
将所有参数按字母排序之后转换成JSON字符串(注意需保持斜杠/和unicode字符串不转义),最后再拼接上token计算MD5值。
|
|
|
|
|
|
|
|
示例如下:
|
|
|
|
```
|
|
|
|
var token = 'hello world'; //config.js里配置的密钥
|
|
|
|
var params = { //参数示例
|
|
|
|
"b": 2,
|
|
|
|
"a": 1,
|
|
|
|
"t": 234343
|
|
|
|
};
|
|
|
|
|
|
|
|
var sortObj = function(obj) { //参数排序方法
|
|
|
|
return Object.keys(obj).sort().reduce(function(result, key) {
|
|
|
|
result[key] = obj[key];
|
|
|
|
return result;
|
|
|
|
}, {});
|
|
|
|
};
|
|
|
|
|
|
|
|
//1. 排序参数
|
|
|
|
var sortedParams = sortObj(params);
|
|
|
|
//2. 计算MD5值
|
|
|
|
var sign = md5( JSON.stringify(sortedParams) + token );
|
|
|
|
```
|