以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]腾讯云短信接口问题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=144269) |
||||
-- 作者:新动感时代 -- 发布时间:2019/12/16 7:37:00 -- [求助]腾讯云短信接口问题 我的问题: (1). 下面是腾讯官方短信API 接口,签名字符串生成的文档说明: 签名字符串sig字段:根据公式 sha256(appkey=$appkey&random=$random&time=$time&mobile=$mobile)生成。 此生成公式中有四个参数:(1)appkey( 密匙),(2)random(随机数),(3)time( 时间戳 ),(4)mobile( 手机号) (2) 下面是我用foxtable生成的短信API接口 签名字符串: Dim sj As long \'生成一个随机数 sj = Rand.Next(1000000000,2000000000) Dim dt1 As Date= #01/01/1970 08:03:25# \'生成一个时间戳 Dim dt2 As Date= Date.now() Dim sp As Integer =Math.Round(( dt2-dt1 ).TotalSeconds) Dim appkey As String ( 密匙) Dim random As Long (随机数) Dim time As Integer ( 时间戳 ) Dim moblile As String ( 手机号) Dim aryTmp() As String = {appkey,random,time,moblile} \'命名包含四个参数的数组 Array.Sort(aryTmp) \'数组排序 Dim sig As String = String.Join("", aryTmp) ’将数组生成字符串 sig = Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sig, "SHA256").ToLower() \'sha256算法加密 问题: 代入参数值后,sig 提交腾讯短信API接口审核不通过,提示sig格式不对。 请求老师给指点一下。我是刚入foxtable的老白(年龄55岁),这问题困扰 几天了,劳驾版主老师帮一下忙。谢谢! |
||||
-- 作者:有点蓝 -- 发布时间:2019/12/16 9:01:00 -- 请不要发重复的问题!! 腾讯官方短信api开发文档的链接发上来看看 |
||||
-- 作者:新动感时代 -- 发布时间:2019/12/16 9:32:00 -- [求助]腾讯短信接口的连接 老师,你好!下面是我用到的腾讯短信接口的连接 https://cloud.tencent.com/document/product/382/5976
|
||||
-- 作者:新动感时代 -- 发布时间:2019/12/16 10:03:00 -- [求助]腾讯短信接口问题 Dim sj As Integer \'定义生成一个随机数 sj = Rand.Next(1000000000,2000000000) Dim hc As New HttpClient(" https://yun.tim.qq.com/v5/tlssmssvr/sendsms?sdkappid=1400294998&random=sj ") \'请求短信接口地址 Dim dt1 As Date= #01/01/1970 08:03:25# \'定义生成一个时间戳 Dim dt2 As Date= Date.now() Dim sp As Integer =Math.Round(( dt2-dt1 ).TotalSeconds) Dim appkey As String="26ccd48b4fc028fce1e4ef0b7723bdcd" \'密匙参数 Dim random As Integer= sj \'随机数参数 Dim time As Integer=sp \'时间戳参数 Dim moblile As String ="13589956068" \'手机号参数 Dim aryTmp() As String = {appkey,random,time,moblile} \'定义包含上面四个参数的数组 Array.Sort(aryTmp) \'数组排序 Dim sig As String = String.Join("", aryTmp) \'数组转为字符串 sig = Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(sig, "SHA256") \' sha256算法 Dim params As JArray \'接口参数定义 Dim sign As String Dim nationcode As String Dim tel As JObject Dim tpl_id As Integer Dim jo As New JObject \'定义对象 Dim ja As New JArray ja.Add("123456") \'定义数组 jo("params")= ja jo("sig")=sig jo("sign")="新动感" Dim jo1 As New JObject \'定义字对象 jo1("mobile")="13589956068" jo1("nationcode")="86" \'\'代入注册的参数数值 jo("tel")=jo1 jo("time")=sp \'代入生成的时间戳数值 jo("tpl_id")=497632 \'代入注册的参数数值 hc.content=jo.ToString() Dim ret As String = hc.getData() If hc.rCookies.ContainsKey("error") Then MessageBox.Show(hc.rCookies("error"), "提示", MessageBoxButtons.OK ,MessageBoxIcon.Warning) Else MessageBox.Show( ret) End If |
||||
-- 作者:有点蓝 -- 发布时间:2019/12/16 10:22:00 -- 把附件的代码放到全局代码中
然后参考: Dim sj As Long\'定义生成一个随机数 sj = SmsSenderUtil.getRandom() Dim hc As New HttpClient(" https://yun.tim.qq.com/v5/tlssmssvr/sendsms?sdkappid=1400294998&random= " & sj) \'请求短信接口地址 hc.ContentType = "application/json" Dim appkey As String="26ccd48b4fc028fce1e4ef0b7723bdcd" \'密匙参数 Dim random As Long= sj \'随机数参数 Dim time As Long=SmsSenderUtil.getCurrentTime() \'时间戳参数 Dim moblile As String ="13589956068" \'手机号参数 Dim sig As String = SmsSenderUtil.calculateSignature(appkey , random, time , moblile ) \' sha256算法 Dim params As JArray \'接口参数定义 Dim sign As String Dim nationcode As String Dim tel As JObject Dim tpl_id As Integer Dim jo As New JObject \'定义对象 Dim ja As New JArray ja.Add("123456") \'定义数组 jo("params")= ja jo("sig")=sig jo("sign")="新动感" Dim jo1 As New JObject \'定义字对象 jo1("mobile")="13589956068" jo1("nationcode")="86" \'\'代入注册的参数数值 jo("tel")=jo1 jo("time")=sp \'代入生成的时间戳数值 jo("tpl_id")=497632 \'代入注册的参数数值 hc.content=jo.ToString() Dim ret As String = hc.getData() If hc.rCookies.ContainsKey("error") Then MessageBox.Show(hc.rCookies("error"), "提示", MessageBoxButtons.OK ,MessageBoxIcon.Warning) Else MessageBox.Show( ret) End If [此贴子已经被作者于2019/12/16 10:23:11编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2019/12/16 10:24:00 -- 签名算法参考c#的sdk:https://cloud.tencent.com/document/product/382/5804 |
||||
-- 作者:新动感时代 -- 发布时间:2019/12/16 23:44:00 -- 问题解决了,谢谢版主老师 |