• 大小: 0.75M
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2024-04-30
  • 语言: C#
  • 标签: sdk  阿里云  代码  sd  C#  

资源简介

C#最新阿里云短信验证sdk代码

资源截图

代码片段和文件信息

using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.Dysmsapi.Model.V20170525;
using System;
using System.Threading;

namespace ClassLibrary1
{
    public class Class1
    {
        
            //产品名称:云通信短信API产品开发者无需替换
            const String product = “Dysmsapi“;
            //产品域名开发者无需替换
            const String domain = “dysmsapi.aliyuncs.com“;

            // TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找)
            const String accessKeyId = “yourAccessKeyId“;
            const String accessKeySecret = “yourAccessKeySecret“;
            public static SendSmsResponse sendSms()
            {
                IClientProfile profile = DefaultProfile.GetProfile(“cn-hangzhou“ accessKeyId accessKeySecret);
                DefaultProfile.AddEndpoint(“cn-hangzhou“ “cn-hangzhou“ product domain);
                IAcsClient acsClient = new DefaultAcsClient(profile);
                SendSmsRequest request = new SendSmsRequest();
                SendSmsResponse response = null;
                try
                {

                    //必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码批量调用相对于单条调用及时性稍有延迟验证码类型的短信推荐使用单条调用的方式
                    request.PhoneNumbers = “15000000000“;
                    //必填:短信签名-可在短信控制台中找到
                    request.SignName = “云通信“;
                    //必填:短信模板-可在短信控制台中找到
                    request.TemplateCode = “SMS_1000000“;
                    //可选:模板中的变量替换JSON串如模板内容为“亲爱的${name}您的验证码为${code}“时此处的值为
                    request.TemplateParam = “{\“customer\“:\“123\“}“;
                    //可选:outId为提供给业务方扩展字段最终在短信回执消息中将此值带回给调用者
                    request.OutId = “yourOutId“;
                    //请求失败这里会抛ClientException异常
                    response = acsClient.GetAcsResponse(request);

                }
                catch (ServerException e)
                {
                    Console.WriteLine(e.ErrorCode);
                }
                catch (ClientException e)
                {
                    Console.WriteLine(e.ErrorCode);
                }
                return response;

            }

            public static SendBatchSmsResponse sendSmss()
            {
                IClientProfile profile = DefaultProfile.GetProfile(“cn-hangzhou“ accessKeyId accessKeySecret);
                DefaultProfile.AddEndpoint(“cn-hangzhou“ “cn-hangzhou“ product domain);

                IAcsClient acsClient = new DefaultAcsClient(profile);
                SendBatchSmsRequest request = new SendBatchSmsRequest();
                //request.Protocol = ProtocolType.HTTPS;
                //request.TimeoutInMilliSeconds = 1;

                SendBatchSmsResponse response = null;
                try
                {

                    //必填:待发送手机号。支持JSON格式的批量调用,批量上限为100个手机号码批量调用相对于单条调用及时性稍有延迟验证码类型的短信推荐使用单条调用的方式
                    request.PhoneNumberJson = “[\“1500000000\“\“1500000001\“]“;
    

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2020-08-12 16:27  AliYunTestMsg\
     目录           0  2020-08-12 16:27  AliYunTestMsg\.vs\
     目录           0  2020-08-12 16:28  AliYunTestMsg\.vs\TestMsg\
     目录           0  2020-08-12 16:27  AliYunTestMsg\.vs\TestMsg\DesignTimeBuild\
     文件      360354  2020-08-12 16:32  AliYunTestMsg\.vs\TestMsg\DesignTimeBuild\.dtbcache
     目录           0  2020-08-12 16:31  AliYunTestMsg\.vs\TestMsg\v15\
     文件       24576  2020-08-12 16:32  AliYunTestMsg\.vs\TestMsg\v15\.suo
     目录           0  2020-08-12 16:28  AliYunTestMsg\.vs\TestMsg\v15\Server\
     目录           0  2020-08-12 16:28  AliYunTestMsg\.vs\TestMsg\v15\Server\sqlite3\
     文件           0  2020-08-12 16:28  AliYunTestMsg\.vs\TestMsg\v15\Server\sqlite3\db.lock
     文件        4096  2020-08-12 16:28  AliYunTestMsg\.vs\TestMsg\v15\Server\sqlite3\storage.ide
     文件       32768  2020-08-12 16:32  AliYunTestMsg\.vs\TestMsg\v15\Server\sqlite3\storage.ide-shm
     文件      951752  2020-08-12 16:32  AliYunTestMsg\.vs\TestMsg\v15\Server\sqlite3\storage.ide-wal
     目录           0  2020-08-12 16:27  AliYunTestMsg\.vs\TestMsg\v16\
     文件       28160  2020-08-12 16:27  AliYunTestMsg\.vs\TestMsg\v16\.suo
     目录           0  2020-08-12 16:27  AliYunTestMsg\.vs\TestMsg\v16\Server\
     目录           0  2020-08-12 16:27  AliYunTestMsg\.vs\TestMsg\v16\Server\sqlite3\
     文件           0  2020-08-12 11:59  AliYunTestMsg\.vs\TestMsg\v16\Server\sqlite3\db.lock
     文件     1314816  2020-08-12 16:27  AliYunTestMsg\.vs\TestMsg\v16\Server\sqlite3\storage.ide
     目录           0  2020-08-12 16:27  AliYunTestMsg\ClassLibrary1\
     目录           0  2020-08-12 16:27  AliYunTestMsg\ClassLibrary1\bin\
     目录           0  2020-08-12 16:27  AliYunTestMsg\ClassLibrary1\bin\Debug\
     目录           0  2020-08-12 16:27  AliYunTestMsg\ClassLibrary1\bin\Debug\netcoreapp3.1\
     文件      183296  2018-05-28 16:41  AliYunTestMsg\ClassLibrary1\bin\Debug\netcoreapp3.1\aliyun-net-sdk-core.dll
     文件       18944  2018-02-05 21:54  AliYunTestMsg\ClassLibrary1\bin\Debug\netcoreapp3.1\aliyun-net-sdk-dysmsapi.dll
     文件        1255  2020-08-12 13:24  AliYunTestMsg\ClassLibrary1\bin\Debug\netcoreapp3.1\ClassLibrary1.deps.json
     文件        8192  2020-08-12 13:24  AliYunTestMsg\ClassLibrary1\bin\Debug\netcoreapp3.1\ClassLibrary1.dll
     文件        1916  2020-08-12 13:24  AliYunTestMsg\ClassLibrary1\bin\Debug\netcoreapp3.1\ClassLibrary1.pdb
     文件         493  2020-08-12 13:23  AliYunTestMsg\ClassLibrary1\ClassLibrary1.csproj
     文件        8629  2020-08-12 13:23  AliYunTestMsg\ClassLibrary1\metd.cs
     目录           0  2020-08-12 16:27  AliYunTestMsg\ClassLibrary1\obj\
............此处省略65个文件信息

评论

共有 条评论