2023-01-31 15:07:26 来源: 互联网
【资料图】
狐表帮助文档里的用httpClient调用阿里云接口的案例(
http://www.foxtable.com/mobilehelp/index.htm?page=0246.htm ),是阿里云的第三方平台市场购买的。好处就是选择多,配置简单,但是如果您是想发送淘宝营销推广短信,您是没办法通过短信备案的。基本都说您是营销短信,不允许备案。
所以我就只能用阿里云官方的短信接口。论坛里也有好几个这样的代码案例,但是都不全,要自己思考修改,我这里整理完整能用的。
dll下载链接:
https://pan.baidu.com/s/1dbUc7T-XbJGHyNZF2b9gYQ
提取码:rbhn
引用阿里云短信提供的net2.0版本的dll接口文件
去阿里云的官网,注册账号,开通短信模块,得到短信签名和短信模板名称。这个自行摸索,我不教你,这个不难的。如果连这个你都摸索不会,你别研究短信接口了。
Dim product As String = "Dysmsapi" "无需更改,官方名称Dim domain As String = "dysmsapi.aliyuncs.com" "无需更改,官方名称Dim accessId As String = "xxx" "更换为您的AccessKeyDim accessSecret As String = "xxx" "更换为您的AccessSecretDim 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 response As Aliyun.Acs.Dysmsapi.Model.V20170525.SendSmsResponse = NothingTry request.PhoneNumbers = "13827126079" request.SignName = "迈宝伦科技" "更换为您备案的短信签名 request.TemplateCode = "SNS_1234343245" "更换您备案的短信模板 request.TemplateParam = "{""customer"":""123""}" "如果您有可替换的标签,可以设置设置json,也可以注释掉 "request.OutId = "YourID" "这玩意暂时没用 response = acsClient.GetAcsResponse(request) MessageBox.show(response.Message) "这里输出发送结果."OK"就是行了.Catch ex As Exception MessageBox.show("短信代码有问题,请联系技术员")End TryCOPY
如果你真的只是发验证码类短信,不是发广告短信,那你用下面的方法
https://market.aliyun.com/products/56928004/cmapi027240.html?spm=5176.730005.productlist.d_cmapi027240.xy5oIm#sku=yuncode2124000000
参考帮助文档:
http://www.foxtable.com/mobilehelp/index.htm?page=0246.htm
只需要买了以后,改掉AppCode就搞定了,超级简单啊
Dim hc As New HttpClient("http://feginesms.market.alicloudapi.com/codeNotice?param=123456&phone=17703940712&sign=1&skin=1")hc.Headers.Add("Authorization","APPCODE " & "xxx请改自己xxx")Dim jo As JObject = Jobject.Parse(hc.GetData)Output.Show(jo.ToString)