日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

用python控制钉钉软件_Python—实现钉钉后台开发

發布時間:2024/7/5 python 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用python控制钉钉软件_Python—实现钉钉后台开发 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

二、實現釘釘免登流程

免登流程分四步:1、前端獲取釘釘免登授權碼code;2、后端獲取access_token;3、使用授權碼code和access_token換取用戶userid;4、通過access_token和userid換取用戶詳情userinfo。

前端獲取授權碼code。

// 獲取當前網頁的url:http://ding-web.lnexin.cn/?corpid=ding46a9582af5b7541b35c2f4657eb6378f

var currentUrl = document.location.toString()

$("#url").append(currentUrl)

// 解析url中包含的corpId

var corpId = currentUrl.split("corpid=")[1];

$("#corpId").append(corpId)

// 釘釘sdk初始化:dd.ready參數為回調函數,在環境準備就緒時觸發,jsapi的調用需要保證在該回調函數觸發后調用,否則無效。

dd.ready(function () {

// 使用SDK 獲取免登授權碼

dd.runtime.permission.requestAuthCode({

corpId: 'dingovyrjosjwioznxqn',

onSuccess: function (result) {

alert(JSON.stringify(result));

var code = result.code;

//$.get("http://49.232.56.68:8006/get/user",'code='+info.code,function(response){

$.get("http://49.232.56.68:8006/get/user?code=" + code, function (response) {

var response = JSON.parse(response)

// 下面的業務根據自己的需求來寫

if (response.user) {

for (item in response.user) {

$("#result").append("

\t[user 屬性] " + item + " : " + response.user[item] + "")

}

}

});

},

onFail: function(err) {

alert('fail: ' + JSON.stringify(err)); //處理失敗的情況

},

});

});

// 如果沒有走ready方法的話會走error方法。

// dd.error(function(error){

dd.error((error) => {

alert('dd error: ' + JSON.stringify(error));

alert(`dd error: ${JSON.stringify(error)}`);

});

后臺獲取access_token,然后獲取userId,最后換取userInfo。

class AdminUser(BaseHandler):

def get(self):

info = self.request.arguments

code = self.get_argument("code", None)

# 獲取access_token

AppKey = "ding4itesoimljq9ksmz"

AppSecret = "BW8XFsbesRJdOjmt_peYOQBTwVWUkQKONxZ2_2_fXhBQjmgq2Q6tRWrq867l84ht"

url = "https://oapi.dingtalk.com/gettoken?appkey={0}&appsecret={1}".format(AppKey, AppSecret)

resp = requests.get(url)

resp = resp.json()

access_token = resp["access_token"]

# 獲取userId

url1 = "https://oapi.dingtalk.com/user/getuserinfo?access_token={0}&code={1}".format(access_token, code)

resp1 = requests.get(url1)

resp1 = resp1.json()

# 獲取userInfo

url2 = "https://oapi.dingtalk.com/user/get?access_token={0}&userid={1}".format(access_token, resp1["userid"])

resp2 = requests.get(url2)

resp2 = resp2.json()

return self.write(json.dumps({"status": "success", "userinfo": resp2}))

三、獲取釘釘后臺人員

四、

總結

以上是生活随笔為你收集整理的用python控制钉钉软件_Python—实现钉钉后台开发的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。