TencentCloud.go 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. package utils
  2. import (
  3. SysConfig "mtp2_if/config"
  4. "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
  5. "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
  6. faceid "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/faceid/v20180301"
  7. )
  8. var TencenCloudFaceIdClient *faceid.Client
  9. // InitTencentCloudClient 初始化Client
  10. func InitTencentCloudClient() (err error) {
  11. secretId := SysConfig.SerCfg.TencentCloudCfg.SecretId
  12. secretKey := SysConfig.SerCfg.TencentCloudCfg.SecretKey
  13. // 实例化一个认证对象,入参需要传入腾讯云账户secretId,secretKey,此处还需注意密钥对的保密
  14. // 密钥可前往https://console.cloud.tencent.com/cam/capi网站进行获取
  15. credential := common.NewCredential(
  16. secretId,
  17. secretKey,
  18. )
  19. // 实例化一个client选项,可选的,没有特殊需求可以跳过
  20. cpf := profile.NewClientProfile()
  21. cpf.HttpProfile.Endpoint = SysConfig.SerCfg.TencentCloudCfg.FaceIdEndPoint
  22. TencenCloudFaceIdClient, err = faceid.NewClient(credential, "", cpf)
  23. if err != nil {
  24. return
  25. }
  26. return
  27. }