Skip to content
master
Switch branches/tags
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.

README.md

Abp.Sms.TencentCloud

ABP version NuGet NuGet Download GitHub stars

Abp TencentCloud SMS module.

Installation

  1. Install the following NuGet packages. (see how)

    • EasyAbp.Abp.Sms.TencentCloud
  2. Add DependsOn(typeof(AbpSmsTencentCloudModule)) attribute to configure the module dependencies. (see how)

Usage

  1. Configure by AbpTencentCloudCommonOptions and AbpTencentCloudSmsOptions.

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.AddAlwaysAllowAuthorization();
        
        Configure<AbpTencentCloudCommonOptions>(op =>
        {
            op.SecretId = "pUqsqkj1EhAYJXbSjRupWDviPAMyEaSrH5vY";
            op.SecretKey = "20DDOExLNQCTRcsogtP9AEQHI1Tcnu5R";
        });
        
        Configure<AbpTencentCloudSmsOptions>(op =>
        {
            op.DefaultSmsSdkAppid = "1400000000";
            op.DefaultSign = "多态科技";
        });
    }

    You can also use ABP settings to control the values of the above options. We recommend to you a great tool module to manage settings: Abp.SettingUI.

  2. Try to send a SMS message.

    var code = "123456";    // The generated verification code
    var templateId = "400000";  // TencentCloud SMS template ID
    var phoneNumber = "+8613000000000";
    
    var smsSender = ServiceProvider.GetRequiredService<ISmsSender>();
    
    // The "text" param has no effect in TencentCloud SMS, but it cannot be null or empty.
    const string text = "placeholder";
    var smsMessage = new SmsMessage(phoneNumber, text);
    smsMessage.Properties.Add(AbpSmsTencentCloudConsts.TemplateIdPropertyName, templateId);
    smsMessage.Properties.Add(AbpSmsTencentCloudConsts.TemplateParamSetPropertyName, new [] {code});
    
    await smsSender.SendAsync(smsMessage);