Baidu Cloud Engine (BCE) SMS driver for smsutils.
This module implements the model.Driver / model.Client interfaces of the core
smsutils library on top of the Baidu Cloud bce-sdk-go SMS service.
Driver name: bce
go get go.gh.ink/smsutils/bce/v3Blank-import this package so it registers itself, then configure it via the core client.
import (
"go.gh.ink/smsutils/v3/client"
"go.gh.ink/smsutils/v3/model"
_ "go.gh.ink/smsutils/bce/v3"
)
clients, err := client.NewClient(model.Config{
Credentials: model.C{
"bce": {
"accessKeyID": "<your-access-key-id>",
"secretAccessKey": "<your-secret-access-key>",
// Optional override:
// "endpoint": "sms.bj.baidubce.com",
},
},
})
if err != nil {
panic(err)
}
// "sender" is the BCE SignatureId; "smsTpl..." is the template code.
err = clients["bce"].SendMessage("+8617601205205", "<signature-id>", "smsTpl:abc123", model.Vars{
{Key: "code", Value: "1234"},
})| Key | Constant | Required | Default | Description |
|---|---|---|---|---|
accessKeyID |
AccessKeyID |
Yes | — | BCE Access Key ID |
secretAccessKey |
SecretAccessKey |
Yes | — | BCE Secret Access Key |
endpoint |
Endpoint |
No | sms.bj.baidubce.com |
API endpoint |
Missing accessKeyID or secretAccessKey yields errors.ErrDriverCredentialInvalid.
- The destination is normalized via
utils.ProcessNumberForChinesebefore sending. templatemaps to the BCETemplate;sendermaps toSignatureId.varsare passed by key asContentVar(map[string]any), so eachVar.Keymust match a placeholder name in your template.- A BCE result
Codeof1000indicates success. Any other code produceserrors.ErrDriverSendFailed, decorated with the provider code, message, request ID and raw result.
- Go 1.25.0+
go.gh.ink/smsutils/v3- Baidu Cloud SDK:
github.com/baidubce/bce-sdk-go