55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
|
package lib
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
func TestDingding_GetAccessToken(t *testing.T) {
|
||
|
ding, err := NewDing("ding5gt8t4uvu2qnz1pt", "l1eiahyX8TzFVfVaxcLA8ic4h00h6MZw3lHhHNHDQTAWN_3R6dlwbLXnmcCSWHI6")
|
||
|
if err != nil {
|
||
|
log.Println(err)
|
||
|
return
|
||
|
}
|
||
|
accessToken, err := ding.GetAccessToken(true)
|
||
|
log.Println(accessToken, err)
|
||
|
/**
|
||
|
{
|
||
|
"accessToken": "91b39cd5952c3a27a6145d9f7fe072a1",
|
||
|
"expireIn": 7200
|
||
|
}
|
||
|
**/
|
||
|
}
|
||
|
func TestDingding_BatchSend(t *testing.T) {
|
||
|
ding, err := NewDing("ding5gt8t4uvu2qnz1pt", "l1eiahyX8TzFVfVaxcLA8ic4h00h6MZw3lHhHNHDQTAWN_3R6dlwbLXnmcCSWHI6")
|
||
|
if err != nil {
|
||
|
log.Println(err)
|
||
|
return
|
||
|
}
|
||
|
//userid
|
||
|
uids := []string{
|
||
|
"4760560137749536",
|
||
|
}
|
||
|
//robotCode
|
||
|
robotCode := "ding5gt8t4uvu2qnz1pt"
|
||
|
content := "你好"
|
||
|
res, err := ding.BatchSend(robotCode, uids, content)
|
||
|
log.Println(res, err)
|
||
|
|
||
|
}
|
||
|
func TestDingding_SendGroup(t *testing.T) {
|
||
|
ding, err := NewDing("ding5gt8t4uvu2qnz1pt", "l1eiahyX8TzFVfVaxcLA8ic4h00h6MZw3lHhHNHDQTAWN_3R6dlwbLXnmcCSWHI6")
|
||
|
if err != nil {
|
||
|
log.Println(err)
|
||
|
return
|
||
|
}
|
||
|
//userid
|
||
|
//robotCode
|
||
|
robotCode := "ding5gt8t4uvu2qnz1pt"
|
||
|
content := "你好"
|
||
|
openConversationId := "cidDrGzCji11c5ZuS7wluktsg=="
|
||
|
res, err := ding.SendGroup(openConversationId, robotCode, content)
|
||
|
log.Println(res, err)
|
||
|
|
||
|
}
|