以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 中国移动企信通短信平台 HTTP接口 有说明文档,求代码 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=142537) |
||||
-- 作者:pc005637 -- 发布时间:2019/10/30 11:24:00 -- 中国移动企信通短信平台 HTTP接口 有说明文档,求代码 说明文档附上,有C#的示例代码,编程小白,只会狐表的代码。能否帮忙转化一下示例,只要发短信那段代码,其它的就可以参考了。谢谢。 [此贴子已经被作者于2019/10/30 11:26:00编辑过]
|
||||
-- 作者:pc005637 -- 发布时间:2019/10/30 11:27:00 -- 好像上传不了pdf,加了txt后缀了。 好像上传不了pdf,压缩成zip了
[此贴子已经被作者于2019/10/30 11:27:40编辑过]
|
||||
-- 作者:pc005637 -- 发布时间:2019/10/30 11:30:00 -- 示例C#代码 5.2. C# using System; using System.Web; using System.Text; using System.Data; using System.IO; using System.Net; using System.Data.SqlClient; using System.Security.Cryptography; namespace DEMO { public class SendMessageHelloWorld { /// <summary> /// POST 发送短信返回结果 /// </summary> /// <returns></returns> public static string PostSendMessage() { string url = "http://120.197.89.51/SmsHttpInterface/smsService/Do-sendSms.action"; string Eid = "qxt"; // 企业账号 string Userid = "admin"; // 用户名 string Password = "123456"; // 密码 string MessageC; // 短信内容 string Mobiles = "13888888888"; // 发送号码,多个号码用 , 隔开 string ExtendAccessNum = ""; // 扩展号 string key = "0000000000000000";// 密钥 StringBuilder sb = new StringBuilder(); sb.Append("eid=" + Encrypt(Eid, key) + "&userid=" + Encrypt(Userid, key) + "&password=" + Encrypt(Password, key) + "&c">Encrypt(MessageContent, key) + "&mobile=" + Encrypt(Mobiles, key) + "&extport=" + Encrypt(ExtendAccessNum, key)); byte[] bData = Encoding.GetEncoding("UTF-8").GetBytes(sb.ToString().Replace("+", "%2b")); HttpWebRequest hwRequest; HttpWebResponse hwResponse; string strResult = string.Empty; try { hwRequest = (HttpWebRequest)WebRequest.Create(url); hwRequest.Method = "POST"; hwRequest.C; hwRequest.ContentLength = bData.Length; Stream smWrite = hwRequest.GetRequestStream(); smWrite.Write(bData, 0, bData.Length); smWrite.Close(); hwResponse = (HttpWebResponse)hwRequest.GetResponse(); StreamReader srReader = new StreamReader(hwResponse.GetResponseStream(), Encoding.GetEncoding("UTF-8")); strResult = srReader.ReadToEnd(); if(strResult.StartsWith("0,")){// 判断返回成功后解密 strResult = strResult.Substring(2); strResult = Decrypt(strResult,key); } srReader.Close(); hwResponse.Close(); } catch { ;} return strResult; }
|
||||
-- 作者:有点蓝 -- 发布时间:2019/10/30 12:05:00 -- 全局代码 Public Function Encrypt(ByVal toEncrypt As String, ByVal key As String) As String Dim keyArray = Encoding.GetEncoding("UTF-8").GetBytes(key) Dim toEncryptArray = Encoding.GetEncoding("UTF-8").GetBytes(toEncrypt) Using acsp = New System.Security.Cryptography.AesCryptoServiceProvider acsp.KeySize = 128 acsp.BlockSize = 128 acsp.GenerateIV() Using aes = New System.Security.Cryptography.AesCryptoServiceProvider aes.Key = keyArray aes.IV = acsp.IV aes.Mode = System.Security.Cryptography.CipherMode.ECB aes.Padding = System.Security.Cryptography.PaddingMode.PKCS7 Dim resultArray As Byte() Using cTransform = aes.CreateEncryptor() resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length) End Using Return Convert.ToBase64String(resultArray) End Using End Using End Function Public Function Decrypt(ByVal toDecrypt As String, ByVal key As String) As String Dim keyArray = Encoding.GetEncoding("GB2312").GetBytes(key) Dim toDecryptArray = Convert.FromBase64String(toDecrypt) Using acsp = New System.Security.Cryptography.AesCryptoServiceProvider acsp.KeySize = 128 acsp.BlockSize = 128 acsp.GenerateIV() Using aes = New System.Security.Cryptography.AesCryptoServiceProvider aes.Key = keyArray aes.IV = acsp.IV aes.Mode = System.Security.Cryptography.CipherMode.ECB aes.Padding = System.Security.Cryptography.PaddingMode.PKCS7 Dim resultArray As Byte() Using cTransform = aes.CreateDecryptor() resultArray = cTransform.TransformFinalBlock(toDecryptArray, 0, toDecryptArray.Length) End Using Return Encoding.GetEncoding("UTF-8").GetString(resultArray) End Using End Using End Function 命令窗口调用 Dim url As String = "http://120.197.89.51/SmsHttpInterface/smsService/Do-sendSms.action" Dim Eid As String = "qxt" Dim Userid As String = "admin" Dim Password As String = "123456" Dim MessageContent As String = "c#测试短信发送" Dim Mobiles As String = "13888888888" Dim ExtendAccessNum As String = "" Dim key As String = "0000000000000000" Dim hc As New HttpClient(url) hc.ContentType = "application/x-www-form-urlencoded" \' hc.FormData.Add("eid",Encrypt(Eid, key).Replace("+", "%2b")) hc.FormData.Add("userid",Encrypt(Userid, key).Replace("+", "%2b")) hc.FormData.Add("password",Encrypt(Password, key).Replace("+", "%2b")) \'其它参数参考实例自己补齐 Dim ret As String = hc.GetData msgbox(Decrypt(ret ,key)) [此贴子已经被作者于2019/10/30 14:51:37编辑过]
|
||||
-- 作者:pc005637 -- 发布时间:2019/10/30 14:49:00 -- 红圈里的代码,需要的吗?(查回原代码,知道了) 如题 此主题相关图片如下:微信截图_20191030144809.png [此贴子已经被作者于2019/10/30 14:52:54编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2019/10/30 14:51:00 -- hc.ContentType = "application/x-www-form-urlencoded" \' |