有度 Golang 版 SDK

flc1125發表於2022-06-24

地址

github.com/go-packagist/youdu

安裝

go get github.com/go-packagist/youdu

使用

package main

import (
    "github.com/go-packagist/youdu"
    "github.com/go-packagist/youdu/message"
    "log"
)

func main() {
    yd := youdu.New(&youdu.Config{
        Api:    "http://domain.com/api",
        Buin:   1111111,
        AppId:  "22222222222222",
        AesKey: "3444444444444444444444444444444444",
    })

    yd.Message().SendText("11111", "test")
    yd.Message().Send(&message.TextMessage{
        ToUser:  "11111",
        ToDept:  "",
        MsgType: message.MsgTypeText,
        Text: &message.TextItem{
            Content: "test",
        },
    })

    mediaId, err := yd.Media().Upload(youdu.MediaTypeImage, "test.jpeg")
    if err != nil {
        panic(err)
    }
    yd.Message().Send(&message.ImageMessage{
        ToUser:  "11111",
        ToDept:  "",
        MsgType: message.MsgTypeImage,
        Image: &message.MediaItem{
            MediaId: mediaId,
        },
    })

}

參考資料

  • 有度 API 官方文件:youdu.im/doc/api/c01_00001.html

相關文章