有没有大佬分享一下阿里云短信所谓的升级版SDK的demo,手册看了半天也没看懂,网上也没有资料。

旧版这个会用,网上搜的也都是旧版使用方法。新版这个实在看不懂,只给了个初始化客户端就没了,怎么传手机号验证码也没找到。实在不行就只能继续用旧版了。
放上官网升级版demo:

// This file is auto-generated, don't edit it. Thanks.
package main

import (
  "os"
  dysmsapi20170525  "github.com/alibabacloud-go/dysmsapi-20170525/v2/client"
  openapi  "github.com/alibabacloud-go/darabonba-openapi/client"
  "github.com/alibabacloud-go/tea/tea"
)


/**
 * 使用AK&SK初始化账号Client
 * @param accessKeyId
 * @param accessKeySecret
 * @return Client
 * @throws Exception
 */
func CreateClient (accessKeyId *string, accessKeySecret *string) (_result *dysmsapi20170525.Client, _err error) {
  config := &openapi.Config{
    // 您的AccessKey ID
    AccessKeyId: accessKeyId,
    // 您的AccessKey Secret
    AccessKeySecret: accessKeySecret,
  }
  // 访问的域名
  config.Endpoint = tea.String("dysmsapi.aliyuncs.com")
  _result = &dysmsapi20170525.Client{}
  _result, _err = dysmsapi20170525.NewClient(config)
  return _result, _err
}

func _main (args []*string) (_err error) {
  client, _err := CreateClient(tea.String("accessKeyId"), tea.String("accessKeySecret"))
  if _err != nil {
    return _err
  }

  addShortUrlRequest := &dysmsapi20170525.AddShortUrlRequest{
    ResourceOwnerAccount: tea.String("your_value"),
    ResourceOwnerId: tea.Int64(1),
    SourceUrl: tea.String("your_value"),
    ShortUrlName: tea.String("your_value"),
  }
  // 复制代码运行请自行打印 API 的返回值
  _, _err = client.AddShortUrl(addShortUrlRequest)
  if _err != nil {
    return _err
  }
  return _err
}


func main() {
  err := _main(tea.StringSlice(os.Args[1:]))
  if err != nil {
    panic(err)
  }
}
讨论数量: 2

放个新版的链接呗 都是懒人

3周前 评论
pardon110

Request 业务参数配置错误, 发短信用 SendSmsRequest

file

3周前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!