关于go:有度-Golang-版-SDK

34次阅读

共计 754 个字符,预计需要花费 2 分钟才能阅读完成。

地址

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

正文完
 0