阿里云微服务消息队列管控API Go SDK使用示例

Step By Step

1、SDK下载

go get -u github.com/aliyun/alibaba-cloud-sdk-go/sdk

2、Code Sample

package main

import (
    "fmt"
    "time"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/onsmqtt"
)

func main() {
    client, err := onsmqtt.NewClientWithAccessKey("mq-internet-access", "<accesskey>", "<accesssecret>")

    request := onsmqtt.CreateApplyTokenRequest()
    request.Scheme = "http"

    request.Resources = "demo-test/+"
    request.InstanceId = "post-cn-6ja********"
    request.ExpireTime = "<毫秒时间戳>"
    request.Actions = "R,W"
    var t int32
    t = 60
    request.ConnectTimeout = time.Duration(t) * time.Second

    response, err := client.ApplyToken(request)
    if err != nil {
        fmt.Print(err.Error())
    }
    fmt.Printf("response is %#v\n", response)
}

ApplyToken API参数说明

3、测试结果
阿里云微服务消息队列管控API Go SDK使用示例

更多参考

阿里云SDK核心库(Core SDK)使用教程
阿里云新版人脸识别Go语言调用示例
阿里云常见参数获取位置

上一篇:静态路由默认路由的配置


下一篇:**使用 Git Hook 实现网站的自动部署