蛋蛋星球-制度模式
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

28 satır
1.2 KiB

  1. package aliyun
  2. import (
  3. openapi "github.com/alibabacloud-go/darabonba-openapi/v2/client"
  4. dypnsapi20170525 "github.com/alibabacloud-go/dypnsapi-20170525/v2/client"
  5. "github.com/alibabacloud-go/tea/tea"
  6. )
  7. // Description:
  8. // 使用AK&SK初始化账号Client
  9. // @return Client
  10. // @throws Exception
  11. func CreateClient(accessKeyId, accessKeySecret string) (_result *dypnsapi20170525.Client, _err error) {
  12. // 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
  13. // 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378661.html。
  14. config := &openapi.Config{
  15. // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
  16. AccessKeyId: tea.String(accessKeyId),
  17. // 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
  18. AccessKeySecret: tea.String(accessKeySecret),
  19. }
  20. // Endpoint 请参考 https://api.aliyun.com/product/Dypnsapi
  21. config.Endpoint = tea.String("dypnsapi.aliyuncs.com")
  22. _result = &dypnsapi20170525.Client{}
  23. _result, _err = dypnsapi20170525.NewClient(config)
  24. return _result, _err
  25. }