Coder Social home page Coder Social logo

dingtalk_suite's Introduction

dingtalk suite

钉钉套件主动调用API, 自带cache

回调server API见:dingtalk_suite_callback

配和企业号 API:dingtalk_enterprise可实现ISV套件控制企业号。 ##安装 npm install dingtalk_suite ##示例 构造函数:

var dd_talk = require('dingtalk_suite');
var conf = {
    suiteid: 'suitexpiygdnxxxxx',
    secret: 'C1oXyeJUgH_QXEHYJS4-Um-zxfxxxxxxxxxxxxxxxxxx-6np3fXskv5dGs',
    getTicket: function(callback){ 
      //从数据库中取出Tikcet,返回的data样式为:{value: 'xxxxxxx', expires:1452735301543}
      //ticket从 dingtalk_suite_callback 处获得
      fs.readFile(this.suiteid + 'ticket.txt',function(err, data){
        if(err){
            return callback(err);
        }
        data = JSON.parse(data.toString());
        callback(null, data);
      });
    },
    
    getToken: function(callback){
      //从数据库中取出Token,返回的data样式为:{value: 'xxxxxxx', expires:1452735301543}
      fs.readFile(this.suiteid + 'token.txt',function(err, data){
        if(err){
            return callback(err);
        }
        data = JSON.parse(data.toString());
        callback(null, data);
      });
    },
    
    saveToken: function(data, callback){
      //存储Token到数据库中,data样式为:{value: 'xxxxxxx', expires:1452735301543//过期时间}
      fs.writeFile(this.suiteid + 'token.txt',JSON.stringify(data), callback);
    }
  }
var api = new dd_talk(conf);

:本项目自带cache, token的过期时间默认为1小时59分50秒(防止网络延迟,故比规定2小时少了10秒)。 可以在conf.token_expires_in更改(不可大于2小时)。 ##方法

获取企业号永久授权码

api.getPermanentCode(tmp_auth_code, callback)

tmp_auth_code字符串,由dingtalk_suite_callback处获得。

获取企业号Token

//auth_corpid和permanent_code由上面接口获得。
api.getCorpToken(auth_corpid, permanent_code, callback)

获取企业号信息

api.getAuthInfo(auth_corpid, permanent_code, callback)

获取企业号应用

api.getAgent(agentid, auth_corpid, permanent_code, callback)

激活授权套件

api.activateSuite(auth_corpid, permanent_code, callback)

为授权方的企业单独设置IP白名单

//ip_whitelist为数组格式:["1.2.3.4","5.6.*.*"]
api.setCorpIpwhitelist(auth_corpid, ip_whitelist, callback)

##更多钉钉相关 ISV套件回调server: dingtalk_suite_callback
企业号API: dingtalk_enterprise
ISV和企业号免登API: dingtalk_sso

dingtalk_suite's People

Contributors

hezedu 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.