Go to file
wyh 3d1d0948d6 fixed mod 2023-12-26 10:34:55 +08:00
.gitignore sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
LICENSE sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
README.md sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
api_attendance.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
api_attendance_test.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
api_calendar.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
api_callback.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
api_callback_test.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
api_contact.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
api_encryption.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
api_encryption_test.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
api_file.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
api_file_test.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
api_media.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
api_message.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
api_robot.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
api_sns.go 组件包sns更新SnsUser、SnsUserID测试完成 2021-11-19 11:33:41 +08:00
api_sns_test.go 组件包sns更新SnsUser、SnsUserID测试完成 2021-11-19 11:33:41 +08:00
crypto.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
go.mod fixed mod 2023-12-26 10:34:55 +08:00
godingtalk.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
godingtalk_test.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
top_api_approval.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
top_api_approval_test.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
top_api_message.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
top_api_message_test.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
top_api_request.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
transport.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
util.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00
util_test.go sns及refreshaccesstoken测试通过 2021-11-18 18:56:31 +08:00

README.md

DingTalk Open API golang SDK

image

Check out DingTalk Open API document at: https://ding-doc.dingtalk.com/

Usage

Fetch the SDK

export GOPATH=`pwd`
go get myschools.me/suguo/godingtalk

Example code to send a micro app message

package main

import (
    "myschools.me/suguo/godingtalk"
    "log"
    "os"
)

func main() {
    c := godingtalk.NewDingTalkClient(os.Getenv("corpid"), os.Getenv("corpsecret"))
    c.RefreshAccessToken()
    err := c.SendAppMessage(os.Args[1], os.Args[2], os.Args[3])
    if err != nil {
        log.Println(err)
    }
}

Guide

Step-by-step Guide to use this SDK

http://hugozhu.myalert.info/2016/05/02/66-use-dingtalk-golang-sdk-to-send-message-on-pi.html

Tools

ding_alert : Command line tool to send app/text/oa ... messages

export GOPATH=`pwd`
go get myschools.me/suguo/godingtalk/demo/ding_alert

export corpid=<组织的corpid 通过 https://oa.dingtalk.com 获取>
export corpsecret=<组织的corpsecret 通过 https://oa.dingtalk.com 获取>

./bin/ding_alert
Usage of ./bin/ding_alert:
  -agent string
    	agent Id (default "22194403")
  -chat string
    	chat id (default "chat6a93bc1ee3b7d660d372b1b877a9de62")
  -file string
    	file path for media message
  -link string
    	link url (default "http://hugozhu.myalert.info/dingtalk")
  -sender string
    	sender id (default "011217462940")
  -text string
    	text for link message (default "This is link text")
  -title string
    	title for link message (default "This is link title")
  -touser string
    	touser id (default "0420506555")
  -type string
    	message type (app, text, image, voice, link, oa) (default "app")

github: Deliver Github webhook events to DingTalk, which can be deployed on Google AppEngine.

more info at: http://hugozhu.myalert.info/2016/05/15/67-use-free-google-cloud-service-to-deliver-github-webhook-events-to-dingtalk.html

export GOPATH=`pwd`
go get myschools.me/suguo/godingtalk/demo/github/appengine

Modify app.yaml

cd src/myschools.me/suguo/godingtalk/demo/github/appengine
cat app.yaml
application: github-alert-<random_number>
version: 1
runtime: go
api_version: go1
env_variables:
  CORP_ID: '<从 http://oa.dingtalk.com 获取>'
  CORP_SECRET: '<从 http://oa.dingtalk.com 获取>'
  GITHUB_WEBHOOK_SECRET: '<从 http://github.com/ 获取>'
  SENDER_ID: '<从 http://open.dingtalk.com 调用api获取>'
  CHAT_ID: '<从 http://open.dingtalk.com 调用api获取>'
handlers:
- url: /.*
  script: _go_app