签名管理
更新时间:2021-05-27
签名管理
申请签名
通过以下代码,可以申请一个SMS签名
// Open file on disk.
f, _ := os.Open("/dir1/dir2/your_sign_pic.png")
// Read entire JPG into byte slice.
reader := bufio.NewReader(f)
content, _ := ioutil.ReadAll(reader)
// Encode as base64.
encoded := base64.StdEncoding.EncodeToString(content)
result, err := client.CreateSignature(&api.CreateSignatureArgs{
Content: "Baidu",
ContentType: "Enterprise",
Description: "test",
CountryType: "DOMESTIC",
SignatureFileBase64: encoded,
SignatureFileFormat: "png",
})
if err != nil {
fmt.Printf("create signature error, %s", err)
return
}
fmt.Printf("create signature success. %s", result)
提示:详细参数配置及限制条件,可以参考SMS API详情创建签名
查询签名
通过以下代码,可以获取一个SMS签名详情
result, err := client.GetSignature(&api.GetSignatureArgs{
SignatureId: "your signature id",
})
if err != nil {
fmt.Printf("get signature error, %s", err)
return
}
fmt.Printf("get signature success. %s", result)
提示:详细参数配置及限制条件,可以参考SMS API详情查询签名
变更签名
通过以下代码,可以变更一个SMS签名申请
// Open file on disk.
f, _ := os.Open("/dir1/dir2/your_sign_pic.png")
// Read entire JPG into byte slice.
reader := bufio.NewReader(f)
content, _ := ioutil.ReadAll(reader)
// Encode as base64.
encoded := base64.StdEncoding.EncodeToString(content)
err := client.ModifySignature(&api.ModifySignatureArgs{
SignatureId: "your signature id",
Content: "Baidu",
ContentType: "MobileApp",
Description: "this is a test",
CountryType: "INTERNATIONAL",
SignatureFileBase64: encoded,
SignatureFileFormat: "png",
})
if err != nil {
fmt.Printf("modify signature error, %s", err)
return
}
fmt.Printf("modify signature success.")
提示:详细参数配置及限制条件,可以参考SMS API详情变更签名
删除签名
通过以下代码,可以删除一个SMS签名
err := client.DeleteSignature(
&api.DeleteSignatureArgs{SignatureId: "your signature id"})
if err != nil {
fmt.Printf("delete signature error, %s", err)
return
}
fmt.Printf("delete signature success.")
提示:详细参数配置及限制条件,可以参考SMS API详情删除签名