sdk下载
https://open.dingtalk.com/document/resourcedownload/download-server-sdk
登录钉钉开发者后台(创建企业内部应用-网页应用, 配置网页应用相关信息,开发模式、服务器出口IP、应用首页地址)
单击应用开发 > 企业内部应用 > 钉钉应用 > 创建应用
设置第三方网站的回调域名
开发配置 > 安全设置,填写重定向 URL(回调域名)
配置应用(权限管理):
开通:个人手机号信息,通讯录个人信息读权限
https://open-doc.dingtalk.com/docs/doc.htm?treeId=168&articleId=104882&docType=1
https://open-doc.dingtalk.com/docs/doc.htm?spm=a219a.7386797.0.0.RwfldF&treeId=172&articleId=104968&docType=1
1.2 二维码内嵌到自己页面中
<script src="//g.alicdn.com/dingding/dinglogin/0.0.2/ddLogin.js"></script>
var obj = DDLogin({
id:"login_container",//这里需要你在自己的页面定义一个HTML标签并设置id,例如<div id="login_container"></div>或<span id="login_container"></span>
goto: "",
style: "",
href: "",
width : "300px",
height: "300px"
});
goto: 需要对整个url进用url编码
https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoags80gxv8z5twqsxu&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http%3A%2F%2Fndj.k8.cn%2Fdd.php
https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=dingoags80gxv8z5twqsxu&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=http%3A%2F%2Fndj.k8.cn%2Fdd.php&loginTmpCode
===================================
https://oapi.dingtalk.com/sns/gettoken?appid=APPID&appsecret=APPSECRET
POST获取用户的永久授权码 unionid 唯一标识
https://oapi.dingtalk.com/sns/get_persistent_code?access_token=ACCESS_TOKEN
{"errcode":0,"errmsg":"ok","openid":"p1Tsd9RsGfgiE","persistent_code":"zFMtUduWeKwQj8xneaYwBoUsAscZMb2r-q1-etmVGOUTbWFqqtaFvDDbj9FN9kfw","unionid":"UvJSEAEiP2bgiE"}
{"errcode":40078,"errmsg":"不存在的临时授权码"}
POST 获取SNS_TOKEN
https://oapi.dingtalk.com/sns/get_sns_token?access_token=ACCESS_TOKEN
GET
https://oapi.dingtalk.com/sns/getuserinfo?sns_token=SNS_TOKEN 7200秒有效
"{"errcode":0,"errmsg":"ok","user_info":{"dingId":"$:LWCP_v1:$PtQ4Jtw+1FWK5trKML6zqQ==","nick":"良苏","openid":"N0VTvMCzV98iE","unionid":"sLdVXiS83lZoiE"}}"
"{"errcode":0,"errmsg":"ok","user_info":{"dingId":"$:LWCP_v1:$hlHQth+GD1bwYHROmonhVw==","nick":"良之雨","openid":"p1Tsd9RsGfgiE","unionid":"UvJSEAEiP2bgiE"}}"