您的位置:首頁 >  接口中心 > 短信接口DEMO-SHELL
  短信接口DEMO-SHELL
 

云通訊平臺-SHELL短信接口開發(fā)示例


#!/bin/sh

# account and password can be change to what you wanna!

#author Yuntongxun

#修改為您的account

account=""

#修改為您的pw

password="a.123456"

#修改為您要發(fā)送的手機號

phone="18712345678"

#設置您要發(fā)送的內容

msg="【云通訊】您的驗證碼是123456。如非本人操作,請忽略。"

echo "send sms:"


#請求地址請登錄云通訊自助通平臺查看或者詢問您的商務負責人獲取

url="https://u.smsyun.cc/sms-partner/access/{用戶帳號}/sendsms"

data="{"account":"$account","password":"$password","phone":"$phone","msg":"$msg","report":"true"}"

curl -H "Content-Type:application/json" -X POST --data $data $url



C# Post.cs


using System;

using System.Data;

using System.Configuration;

using System.Collections;

using System.IO;

using System.Net;

using System.Text;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

using System.Security.Cryptography.X509Certificates;

using System.Net.Security;


public partial class Post : System.Web.UI.Page

{

    public static string PostUrl = ConfigurationManager.AppSettings["WebReference.Service.PostUrl"];

    protected void Page_Load(object sender, EventArgs e)

    {


    }

    protected void ButSubmit_Click(object sender, EventArgs e)

    {

        string un = this.Txtaccount.Text.Trim();

        string pw = this.Txtpassword.Text.Trim();

        string phone = this.Txtmobile.Text.Trim();

        string content = "【云通訊】" + HttpContext.Current.Server.UrlEncode(this.Txtcontent.Text.Trim());



        string postJsonTpl = ""account":"{0}","password":"{1}","phone":"{2}","report":"false","msg":"{3}"";

        string jsonBody = string.Format(postJsonTpl, un, pw, phone, content);

        string result = doPostMethodToObj("https://u.smsyun.cc/sms-partner/access/{用戶帳號}/sendsms", "{" + jsonBody + "}");//請求地址請登錄云通訊平臺查看或者詢問您的商務負責人獲取

        LabelRetMsg.Text = result;


    }


    public static string doPostMethodToObj(string url, string jsonBody)

    {

        string result = String.Empty;

        HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);

        httpWebRequest.ContentType = "application/json";

        httpWebRequest.Method = "POST";


        // Create NetworkCredential Object 

        NetworkCredential admin_auth = new NetworkCredential("username", "password");


        // Set your HTTP credentials in your request header

        httpWebRequest.Credentials = admin_auth;


        // callback for handling server certificates

        ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };


        using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))

        {

            streamWriter.Write(jsonBody);

            streamWriter.Flush();

            streamWriter.Close();

            HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))

            {

                result = streamReader.ReadToEnd();

            }

        }

        return result;

    }


}


免费视频观无码一区,国内精品一区二区无码,99精品无码视频在线播放,ā片国产在线播放