以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 腾讯云短信 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=164855) |
||||||||
-- 作者:lshshlxsh -- 发布时间:2021/5/7 9:07:00 -- 腾讯云短信 请问老师 下面代码 在foxtable 要怎么写? Imports System.Threading.Tasks Imports TencentCloud.Common Imports TencentCloud.Common.Profile Imports TencentCloud.Sms.V20190711 Imports TencentCloud.Sms.V20190711.Models Namespace TencentCloudExamples Class SendSms Private Shared Sub Main1(ByVal args As String()) Try Dim cred As Credential = New Credential With { .SecretId = "xxx", .SecretKey = "xxx" } Dim clientProfile As ClientProfile = New ClientProfile() clientProfile.SignMethod = ClientProfile.SIGN_TC3SHA256 Dim httpProfile As HttpProfile = New HttpProfile() httpProfile.ReqMethod = "GET" httpProfile.Timeout = 10 httpProfile.Endpoint = "sms.tencentcloudapi.com" httpProfile.WebProxy = Environment.GetEnvironmentVariable("HTTPS_PROXY") clientProfile.HttpProfile = httpProfile Dim client As SmsClient = New SmsClient(cred, "ap-guangzhou", clientProfile) Dim req As SendSmsRequest = New SendSmsRequest() req.SmsSdkAppid = "1400787878" req.Sign = "xxx" req.ExtendCode = "x" req.SenderId = "" req.SessionContext = "" req.PhoneNumberSet = New String() {"+8613711112222"} req.TemplateID = "449739" req.TemplateParamSet = New String() {"666"} Dim resp As SendSmsResponse = client.SendSmsSync(req) Console.WriteLine(AbstractModel.ToJsonString(resp)) Catch e As Exception Console.WriteLine(e.ToString()) End Try Console.Read() End Sub End Class End Namespace |
||||||||
-- 作者:有点蓝 -- 发布时间:2021/5/7 9:29:00 -- 把dll复制到foxtable安装目录,然后添加引用 public Sub Main1() Try Dim cred As TencentCloud.Common.Credential = New TencentCloud.Common.Credential With { .SecretId = "xxx", .SecretKey = "xxx" } Dim clientProfile As TencentCloud.Common.Profile.ClientProfile = New TencentCloud.Common.Profile.ClientProfile() clientProfile.SignMethod = ClientProfile.SIGN_TC3SHA256 Dim httpProfile As HttpProfile = New HttpProfile() httpProfile.ReqMethod = "GET" httpProfile.Timeout = 10 httpProfile.Endpoint = "sms.tencentcloudapi.com" httpProfile.WebProxy = Environment.GetEnvironmentVariable("HTTPS_PROXY") clientProfile.HttpProfile = httpProfile Dim client As SmsClient = New SmsClient(cred, "ap-guangzhou", clientProfile) Dim req As SendSmsRequest = New SendSmsRequest() req.SmsSdkAppid = "1400787878" req.Sign = "xxx" req.ExtendCode = "x" req.SenderId = "" req.SessionContext = "" req.PhoneNumberSet = New String() {"+8613711112222"} req.TemplateID = "449739" req.TemplateParamSet = New String() {"666"} Dim resp As SendSmsResponse = client.SendSmsSync(req) msgbox(AbstractModel.ToJsonString(resp)) Catch e As Exception msgbox(e.ToString()) End Try End Sub 调用的时候直接调用Main1()函数即可
|
||||||||
-- 作者:lshshlxsh -- 发布时间:2021/5/7 9:47:00 -- 谢谢老师 我dll文件也引入了 但是上述代码放到全局代码 报错 |
||||||||
-- 作者:有点蓝 -- 发布时间:2021/5/7 9:55:00 -- 可能命名空间的问题,自己尝试是哪一个,或者看官方文档、源码 Imports TencentCloud.Common Imports TencentCloud.Common.Profile Imports TencentCloud.Sms.V20190711 Imports TencentCloud.Sms.V20190711.Models 换一个用法 Dim cred As TencentCloud.Common.Credential = New TencentCloud.Common.Credential cred .SecretId = "xxx" cred .SecretKey = "xxx" |
||||||||
-- 作者:lshshlxsh -- 发布时间:2021/5/7 10:44:00 -- 老师 我再调用的时候 出现错误,麻烦帮我看一下 ![]() ![]() [此贴子已经被作者于2021/5/7 10:44:31编辑过]
|
||||||||
-- 作者:有点蓝 -- 发布时间:2021/5/7 10:48:00 -- dll没有添加到foxtable安装目录,或者没有添加引用。 把系统.net framework更新到最新4.8版。 另外注意引用net framework版本的dll,不是net core的版本dll
[此贴子已经被作者于2021/5/7 10:48:46编辑过]
|
||||||||
-- 作者:bobolan521 -- 发布时间:2021/5/19 9:26:00 -- 老师.net安装了4.6 ,麻烦帮我看下,dll也引用了,命名空间也照C#里写了,命令窗口运行还是报这个错 可以运行的C#代码附件我也上传了 全局代码如下: Public Sub Main1() Try Dim cred As TencentCloud.Common.Credential = New TencentCloud.Common.Credential cred .SecretId = "AKIDOYUtON8qV69cZQ2PO8l9UfsrcyKI" cred .SecretKey = "3g5wXtcnhJekcDXbYswUmnXwmPdaG" Dim clientProfile As TencentCloud.Common.Profile.ClientProfile = New TencentCloud.Common.Profile.ClientProfile() Dim httpProfile As TencentCloud.Common.Profile.HttpProfile = New TencentCloud.Common.Profile.HttpProfile() httpProfile.Endpoint = ("sms.tencentcloudapi.com") clientProfile.HttpProfile = httpProfile Dim client As TencentCloud.Sms.V20210111.SmsClient = New TencentCloud.Sms.V20210111.SmsClient(cred, "ap-guangzhou", clientProfile) Dim req As TencentCloud.Sms.V20210111.Models.SendSmsRequest = New TencentCloud.Sms.V20210111.Models.SendSmsRequest() req.PhoneNumberSet = New String() {"+8615968015166"} req.SmsSdkAppId = "1400517359" req.SignName = "测试" req.TemplateId = "947545" req.TemplateParamSet = New String() {"123321"} Dim resp As TencentCloud.Sms.V20210111.Models.SendSmsResponse = client.SendSmsSync(req) msgbox(TencentCloud.Common.AbstractModel.ToJsonString(resp)) \' Catch e As Exception msgbox(e.ToString()) End Try Console.Read() End Sub
[此贴子已经被作者于2021/5/19 15:04:28编辑过]
|
||||||||
-- 作者:有点蓝 -- 发布时间:2021/5/19 10:16:00 -- 把System.Text.Encodings.Web.dll也复制到安装目录 参考这里:http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=149415&authorid=0&page=0&star=3,21楼23楼添加一下配置
|
||||||||
-- 作者:bobolan521 -- 发布时间:2021/5/19 10:52:00 -- 老师好,这个DLL文件我也复制引用的,老师,我加了那个红色代码,狐表都启动不了了 [此贴子已经被作者于2021/5/19 11:19:00编辑过]
|
||||||||
-- 作者:有点蓝 -- 发布时间:2021/5/19 12:16:00 -- 仔细看8楼的链接,不是乱加的,原来的配置不能删除,要加到<runtime><assemblyBinding节点里面 |