Giter Club home page Giter Club logo

alitosign's Introduction

AliToSign

基于nodejs的阿里云API签名生成工具

阿里云签名官方说明

安装方法:

npm install alitosign --save

使用方法:

例子:添加域名

const alitosign = require("alitosign");
const querystring = require("querystring");
const moment = require("moment");
const http =require("http");


//基本上调用�接口都需要的公共参数
let originParams = {
    AccessKeyId: "xxxxxxx", //AccessKeyId 获得方法请参照官方文档
    Format: "JSON",
    Version: "2015-01-09",
    SignatureMethod: "HMAC-SHA1",
    SignatureVersion: "1.0"
}

function AddDomain() {

    //复制一份公共参数
    let params = Object.assign({},originParams); 
    

    //在新的对象上添加你想调用的该接口必要参数,
    //每个接口都不一样,具体请查阅官方文档
    params.Action = "AddDomain";
    params.DomainName = "alili.tech";
    params.GroupId = "2223";

    //添加时间戳
    params.Timestamp = moment.utc().format(); //要用格林威治时间;
    params.SignatureNonce = new Date().getTime();
    
    //生成签名
    let signParams = alitosign(params);

    //将包含签名属性的对象转换成query格式的字符串
    let queryParams = querystring.stringify(signParams);
    
    //拼接url
    let url = `http://alidns.aliyuncs.com/?` + queryParams;

    //调用接口
    http.get(url, (res) => {
        res.on('data', function (data) {

            //序列化之后,就可以拿到你想要的数据了
            let oData = JSON.parse(data);

        });
    })

} 

alitosign's People

Contributors

num142857 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.