宅男噜噜噜66在线观看,亚洲精品一区二区三区精品,亚洲一区二区三区乱码在线欧洲,亚洲精品久久麻豆蜜桃,亚洲色无色a片一区二区

您是否正受到短信簽名報(bào)備的困擾?互億無(wú)線解決方案讓您最快15分鐘內(nèi)恢復(fù)信息傳遞,馬上 注冊(cè)體驗(yàn)。
所有文檔
銀行信息核驗(yàn)
應(yīng)用開(kāi)發(fā)
短信服務(wù)
文檔中心 > 短信服務(wù) > 營(yíng)銷(xiāo)短信

營(yíng)銷(xiāo)短信

C#對(duì)接短信營(yíng)銷(xiāo)批量提交接口接口DEMO示例
本文為您提供了C#語(yǔ)言版本的短信營(yíng)銷(xiāo)批量提交接口接口對(duì)接DEMO示例

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;
using System.Text.Json;

class Program
{
    private const string host = "https://api.ihuyi.com";
    private const string path = "/sms-yx/v1/batchSend";
    private const string method = "POST";

    static void Main(string[] args)
    {
        // 定義請(qǐng)求的數(shù)據(jù)
        var values = new Dictionary<string, object>
        {
        {"api_id": "sms-yx-xxxxxxxx"}, //APIID(用戶中心【文本短信】-【會(huì)員營(yíng)銷(xiāo)短信】-【產(chǎn)品總覽】查看)
        {"signature": "xxxxxxxxx"}, //請(qǐng)求驗(yàn)證加密簽名(非短信簽名);
簽名生成方式:
僅公共參數(shù)以ASCII碼從小到大排序值,key=value,多值以“&”隔開(kāi),拼接之后md5 32位小寫(xiě); 如:md5(api_id=xxxx&api_key=xxxx&request_id=xxxxxxxx&timestamp=xxxxxxx)
APIKEY(用戶中心【文本短信】-【會(huì)員營(yíng)銷(xiāo)短信】-【產(chǎn)品總覽】查看)
2、動(dòng)態(tài)密碼(生成動(dòng)態(tài)密碼方式請(qǐng)看該文檔末尾的說(shuō)明) {"timestamp": 1623643787}, //東八時(shí)區(qū);10位時(shí)間戳,時(shí)間允許相差±60S {"request_id": "xxxxxxxxxxxx"}, //請(qǐng)求方請(qǐng)求ID,建議使用唯一ID,比如使用uuid;我方系統(tǒng)會(huì)2小時(shí)內(nèi)去重驗(yàn)證處理,防止網(wǎng)絡(luò)重復(fù)攻擊; {"product_id": 1001}, //產(chǎn)品ID {"phone": new List<string> { "18800000000", "18800000001" }}, //手機(jī)號(hào)數(shù)組(最多1萬(wàn)個(gè)號(hào)碼) {"sign_name": "xxxxxxxx"}, //短信簽名(template_id未填寫(xiě)則必填) {"content": "尊敬的會(huì)員您好:${name},您的訂單號(hào)是:${order_no},拒收請(qǐng)回復(fù)R"}, //template_id為空時(shí)必填;
短信內(nèi)容,如:您的短信群發(fā)功能已開(kāi)通,請(qǐng)?jiān)?個(gè)工作日之內(nèi)至平臺(tái)進(jìn)行企業(yè)認(rèn)證! 短信內(nèi)容和模板ID必須傳入1個(gè);當(dāng)短信內(nèi)容和模板ID都傳入時(shí),傳入內(nèi)容生效,模板ID屬性失效; {"template_id": 1}, //模板ID(內(nèi)容為空則必填) {"template_var": new Dictionary<string, string> { {"${name}", "張三"}, {"${order_no}", "202009041156181103"} }}, //選擇模板時(shí),且模板是變量模板時(shí),可以傳入變量值,需要傳入json格式; {"send_time": "2020-08-26 16:08:14"}, //定時(shí)發(fā)送時(shí)間 }; // 將數(shù)據(jù)轉(zhuǎn)換為JSON字符串 string jsonBody = JsonSerializer.Serialize(values); byte[] data = Encoding.UTF8.GetBytes(jsonBody); string url = host + path; HttpWebRequest httpRequest = null; HttpWebResponse httpResponse = null; if (host.Contains("https://")) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url)); } else { httpRequest = (HttpWebRequest)WebRequest.Create(url); } httpRequest.Method = method; httpRequest.ContentType = "application/json"; httpRequest.ContentLength = data.Length; // 將JSON數(shù)據(jù)寫(xiě)入請(qǐng)求體 using (Stream stream = httpRequest.GetRequestStream()) { stream.Write(data, 0, data.Length); } try { httpResponse = (HttpWebResponse)httpRequest.GetResponse(); } catch (WebException ex) { httpResponse = (HttpWebResponse)ex.Response; } Console.WriteLine(httpResponse.StatusCode); Console.WriteLine(httpResponse.Method); Console.WriteLine(httpResponse.Headers); Stream st = httpResponse.GetResponseStream(); StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8")); Console.WriteLine(reader.ReadToEnd()); Console.WriteLine("\n"); // 釋放資源 reader.Close(); st.Close(); if (httpResponse != null) httpResponse.Close(); } public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { return true; } }

5分鐘快速自助開(kāi)通免費(fèi)體驗(yàn)賬戶

在線咨詢
電話咨詢

服務(wù)熱線:

4008 808 898

服務(wù)熱線(工作時(shí)間):

4008 808 898

業(yè)務(wù)咨詢(非工作時(shí)間):

售后咨詢(非工作時(shí)間):