钉钉APi组件,仅适用于Web版本。Api所需参数配置请查看Smobiler钉钉Api参数配置
属性 |
属性说明 |
---|---|
AgentID |
AgentID。 |
APPID |
钉钉应用凭证AppKey。 |
AppSecret |
AppSecret。 |
CorpID |
CorpID。 |
方法 |
方法说明 |
---|---|
Config |
JSAPI鉴权,除Scan和Login外都需要先Config。 |
SelectMethod |
选择要调用的方法。 |
Scan |
钉钉扫码 |
OpenSingleChat |
打开与指定用户的单聊会话。 |
GetLocation |
获取地理位置。 |
ExternalComplexPicker |
选择外部联系人。 |
Login |
钉钉登录。 |
事件 |
事件说明 |
---|---|
Afterlogin |
登陆后发生 |
C#: private string AppID = "***********";//请替换成钉钉应用ID,也就是AppKey private string AppSecret = "*********">;//请替换成钉钉APPSercetkey private string CorpID = "*********";//请替换钉钉CorpID private string AgentID = "***********";// 请替换成钉钉AgentId private void button1_Press( object sender, EventArgse) { //生成随机字符 string nonceStr = dingDingApi1.CreatenNonce_str(); //生成时间戳 long timestamp = dingDingApi1.CreatenTimestamp(); token = GetAccessToken(); string< jsticket = GetJsApiTicket(token); //生成签名 sign = dingDingApi1.GetSignature(jsticket, nonceStr, timestamp); string[] jsApiList = new string[] { "biz.util.scan", "device.geolocation.get", "biz.contact.externalComplexPicker", "biz.chat.openSingleChat" }; dingDingApi1.Config(timestamp, nonceStr, sign, jsApiList, (obj, args) => { if (args.isError == true) { Toast( "code; " + args.errorCode + " error: " + args.error); } else Toast( "success"); }); } /// 获取授权access_token private string GetAccessToken() { IDingTalkClient client = new DefaultDingTalkClient( "https://oapi.dingtalk.com/gettoken"); OapiGettokenRequest req = new OapiGettokenRequest(); if ( string<.IsNullOrEmpty(AppID) == true) throw new Exception("Missing AppID"); req.Appkey = AppID; req.Appsecret = AppSecret; req.SetHttpMethod("GET"); OapiGettokenResponse response = client.Execute(req); returnresponse.AccessToken; }
C#: Dictionary<string, object> keyValuePairs = new Dictionary<string, object>() { }; keyValuePairs.Add("type", "all"); dingDingApi1.SelectMethod("biz", "util", "scan", keyValuePairs, (obj, args) => { if (args.isError == false) { if (args.args != null) { string str = ""; Dictionary<string, object> datas = args.args as Dictionary<string, object>; if (datas != null) foreach (KeyValuePair <string, object> keyValue in datas) { str += keyValue.Key + " " + keyValue.Value.ToString(); } Toast(str); } } });
C#: dingDingApi1.Scan(Smobiler.Plugins.DingTalkScanType.All, (obj, args) => { if (args.isError == false) { Toast(args.args.ToString()); } });
C#: //请将 **** 替换钉钉用户的userid dingDingApi1.OpenSingleChat("****", (obj, args) => { if (args.isError == true) { Toast("code; " + args.errorCode + " error: " + args.error); } else Toast("success"); });
C#: dingDingApi1.GetLocation(20, Smobiler.Plugins.DingTalkCoordinate.Amap, true, true, (obj, args) => { if (args.isError == false) { string str = ""; Dictionary<string, object> datas = args.args as Dictionary<string, object>; foreach (KeyValuePair<string, object> keyValue in datas) { str += keyValue.Key + " " + keyValue.Value.ToString(); } Toast(str); } else { Toast(args.error); } });
C#: dingDingApi1.ExternalComplexPicker("titie1", true, "超出了", 10, new string[] { }, new string[] { }, new string[] { }, (obj, args) => { if (args.isError == false) { string str = ""; ArrayList arrayList = (ArrayList)args.args; if (arrayList != null) { foreach (Dictionary<string, object> datas in arrayList) { foreach (KeyValuePair<string, object> keyValue in datas) { str += keyValue.Key + " " + keyValue.Value.ToString(); } } } Toast(str); } else Toast(args.error); });
C#:
dingDingApi1.Login();