开发小程序(HTTP回调)
教程介绍

准备工作
1.
git clone https://github.com/open-dingtalk/pierced.git
2.
./ding -config=./ding.cfg -subdomain=域名前缀 端口
命令,启动该工具。cd 下载目录/pierced/mac_64
./ding -config=./ding.cfg -subdomain=example 8080

步骤一:创建应用
步骤二:服务端开发
1.
git clone https://github.com/opendingtalk/eapp-isv-quick-start-java.git
2.
1.
配置 | 说明 |
---|---|
服务器出口IP | 调用钉钉服务端API的公网IP,多个IP用逗号分隔。 |
|推送类型|选择使用HTTP推送。
|Token|自定义固定字符串,必须为英文或数字,长度为3~32个字符。
|数据加密密钥|回调消息加解密参数,是AES密钥的Base64编码,用于解密回调消息内容对应的密文。
|回调URL|开发者服务器接收推送信息的地址,用于接收钉钉服务器推送的消息。
eapp-isv-quick-start-java/src/main/java/com/controller/IndexController.java
码中查看回调URL。http://example.vaiwan.com/dingCallback
。example.vaiwan.com
是内网穿透工具启动的URL,请根据实际情况进行替换。|2.
eapp-isv-quick-start-java/src/main/java/com/config/Constant.java
文件,提供以下配置:
1.

2.

3.
1.
mvn clean compile -U
2.
mvn clean package -Dmaven.test.skip=true
3.
java -jar target/eapp-isv-quick-start-1.0.0.jar
4.

5.

{
"TimeStamp":1553709079062,
"AuthCode": "80dc451ddc173da686f7e1492axxxx",
"AuthCorpId":"ding2f5d5f95e46aa503ffe9347xxxx",
"EventType":"tmp_auth_code",
"SuiteKey":"suitefcurkdvkc1ncxxxx"
}
4.
1.
https://oapi.dingtalk.com/service/get_suite_token
{
"suite_key":"xxx",
"suite_secret": "xxx",
"suite_ticket": "xxx"
}
参数 | 类型 | 必须 | 说明 |
suite_key | String | 是 | 三方企业应用suitekey,开发者后台创建应用后获取。 |
suite_secret | String | 是 | 三方企业应用suiteSecret,开发者后台创建应用后获取。 |
suiteTicket | String | 是 | 钉钉开放平台会向应用的回调URL推送的suite_ticket,详细内容请参考推送suite_ticket事件。 |
2.
https://oapi.dingtalk.com/service/get_permanent_code?suite_access_token=SUITE_ACCESS_TOKEN
{"tmp_auth_code": "xxx"}
参数 | 类型 | 必须 | 说明 |
suite_access_token | String | 是 | 应用套件suite_access_token,调用 |
|tmp_auth_code|String|是|临时授权码,来自授权开通事件中的AuthCode。
3.
https://oapi.dingtalk.com/service/activate_suite?suite_access_token=SUITE_ACCESS_TOKEN
{
"suite_key":"xxxxxx",
"auth_corpid":"xxxxxx",
"permanent_code":"xxxxxx"
}
参数 | 类型 | 必须 | 说明 |
suite_access_token | String | 是 | 应用套件suite_access_token。 |
suite_key | String | 是 | 三方企业应用suitekey,开发者后台创建应用后获取。 |
auth_corpid | String | 是 | 授权企业corpid。 |
permanent_code | String | 是 | 企业的永久授权码。 |
5.

步骤三:发布小程序
1.
git clone https://github.com/opendingtalk/eapp-isv-project-fe.git
2.

3.
index.js
文件修后端服务URL。本示例输入内网穿透工具中设置的域名。4.

5.

6.

修改于 2021-12-30 06:04:25