以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 短信验证 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=157369) |
-- 作者:刘林 -- 发布时间:2020/10/13 17:34:00 -- 短信验证 yzm = Rand.Next(1000, 9999) Dim phone As String = StrToNarrow(e.Form.Controls("sjhm").text) Dim url As String Dim hc As New HttpClient("http://fesms.market.alicloudapi.com/sms/?code=" & yzm & "&ph&skin=1&sign=175622") hc.Headers.Add("Authorization","APPCODE" & " " & "5b33f5a047df9ba68479b11085f3") Dim result As String = hc.GetData() Dim jo As JObject = Jobject.Parse(result) If jo("Message")="OK" Then e.Sender.Enabled=False e.Form.Controls("yzm").Select() e.Form.Controls("sjhm").Enabled=False e.Form.TimerEnabled = True messagebox.show("验证码短信已发送至手机,请及时输入验证码并确认验证") Else messagebox.show(jo("Message")) End If 请问老师,之前买的阿里云市场的短信包,但现在改为阿里自有的短信包,有accesskey ID请问上面的代码如何代码如何改
|
-- 作者:有点蓝 -- 发布时间:2020/10/13 17:38:00 -- 开发文档链接? |
-- 作者:刘林 -- 发布时间:2020/10/13 17:50:00 -- https://api.aliyun.com/#/?product=Dysmsapi&version=2017-05-25&api=AddSmsSign¶ms={}&tab=DOC&lang=JAVA |
-- 作者:有点蓝 -- 发布时间:2020/10/13 20:12:00 -- 都是调用阿里云提供的sdk的,下载sdk使用:https://help.aliyun.com/document_detail/66509.html?spm=a2c1g.8271268.10000.138.6a8ddf25jwUCBT 用法可以参考论坛百度AI调用百度sdk的用法,大同小异。如果看官方的用法请看.net的用法,不要看java的:https://api.aliyun.com/#/?product=Dysmsapi&version=2017-05-25&api=AddSmsSign¶ms={}&tab=DEMO&lang=CSHARP c#代码转换为vb:http://converter.telerik.com/
|
-- 作者:刘林 -- 发布时间:2020/10/13 21:54:00 -- using System; using System.Collections.Generic; using Aliyun.Acs.Core; using Aliyun.Acs.Core.Profile; using Aliyun.Acs.Core.Exceptions; using Aliyun.Acs.Core.Http; namespace CommonRequestDemo {
class Program {
static
void Main(string[] args) { IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", "<accessKeyId>", "<accessSecret>"); DefaultAcsClient client = new DefaultAcsClient(profile); CommonRequest request = new CommonRequest(); request.Method = MethodType.POST; request.Domain = "dysmsapi.aliyuncs.com"; request.Version = "2017-05-25"; request.Action = "SendSms";
// request.Protocol = ProtocolType.HTTP; request.AddQueryParameters("PhoneNumbers", "13696057348"); request.AddQueryParameters("SignName", "教务帮"); request.AddQueryParameters("TemplateCode", "SMS_24277572"); request.AddQueryParameters("TemplateParam", "{\\"code\\":\\"code\\"}");
try { CommonResponse response = client.GetCommonResponse(request); Console.WriteLine(System.Text.Encoding.Default.GetString(response.HttpResponse.Content)); }
catch (ServerException e) { Console.WriteLine(e); }
catch (ClientException e) { Console.WriteLine(e); } } } } 老师,我按他的提示测试代码.net为上面可以了,但要改成一楼的方式改不来,请帮看下,谢谢 |
-- 作者:有点蓝 -- 发布时间:2020/10/13 22:36:00 -- 和1楼的用法没有半毛钱的关系。 引用dll,把Main里面的代码写全命名空间转换为vb代码直接调用,比如 dim profile = Aliyun.Acs.Core.Profile.DefaultProfile.GetProfile("cn-hangzhou", "<accessKeyId>", "<accessSecret>") dim client as new Aliyun.Acs.Core.DefaultAcsClient(profile) ……
|
-- 作者:刘林 -- 发布时间:2020/10/14 8:32:00 -- 我买的阿里自营的短信API接口,现在是想用一楼的方式调用短信,按楼上的确实弄不好,请老师明示,谢谢 |
-- 作者:有点蓝 -- 发布时间:2020/10/14 8:44:00 -- 阿里云已经封装好了,只能这样用。我没看到有提供http的api接口。所以无法使用1楼的方式 |