首先引用
aliyun-net-sdk-dysmsapi.dll
aliyun-net-sdk-core.dll
代码:
Dim json As String =args(0) ' json代码: "{""name"":"""&
name
&""",""time"":"""&
time
&""",""type"":"""& tp
&""",""dizhi"":"""&
dizhi &""",""beizhu"":"""&
beizhu
&""",""lxr"":"""& lxr
&"""}"
Dim TempCode As String =args(1) ' "SMS_1297***" 使用模板
Dim phs As String=args(2)
Dim product As String =
"Dysmsapi"
Dim domain As String =
"dysmsapi.aliyuncs.com"
Dim accessId As String =
"你的id"
Dim accessSecret As String ="你的密钥"
Dim regionIdForPop As String =
"cn-hangzhou"
Dim profile As
Aliyun.Acs.Core.Profile.IClientProfile = Aliyun.Acs.Core.Profile.DefaultProfile.GetProfile(regionIdForPop,
accessId, accessSecret)
Aliyun.Acs.Core.Profile.DefaultProfile.AddEndpoint(regionIdForPop,
regionIdForPop, product, domain)
Dim acsClient As
Aliyun.Acs.Core.IAcsClient = New Aliyun.Acs.Core.DefaultAcsClient(profile)
Dim request As
Aliyun.Acs.Dysmsapi.Model.V20170525.SendSmsRequest = New
Aliyun.Acs.Dysmsapi.Model.V20170525.SendSmsRequest()
Dim phones() As String =
phs.Split(",")
For Each phone As String In
phones
Dim r As DataRow=DataTables("SMS_Send_Phone").SQLAddNew()
r("content")=""
r("phone")=phone
r("time")=now
Try
request.PhoneNumbers = phone
request.TemplateCode =TempCode ';//管理控制台中配置的审核通过的短信模板的模板CODE(状态必须是验证通过)"
request.SignName = "你的签名"
request.TemplateParam = json
request.OutId =
Guid.NewGuid().ToString().replace("-","")
Dim sendSmsResponse As
Aliyun.Acs.Dysmsapi.Model.V20170525.SendSmsResponse =
acsClient.GetAcsResponse(request)
r("BizId")=sendSmsResponse.BizId
r("tpye")="ALi"
r("RequestId")=sendSmsResponse.RequestId
r("Code")=sendSmsResponse.Code
If
sendSmsResponse.Message.Tostring="OK" Then
Else
End If
Catch e As
Aliyun.Acs.Core.Exceptions.ServerException
Catch e As
Aliyun.Acs.Core.Exceptions.ClientException
End Try
r.save()
Next
Return ""
[此贴子已经被作者于2018/4/11 16:11:50编辑过]