forked from nxtele/http-api-document
-
Notifications
You must be signed in to change notification settings - Fork 1
Sending SMS using C#
dy.Zhuang edited this page Oct 14, 2022
·
1 revision
- C# code example for sending sms
using System;
using System.Net;
using System.Text;
using System.IO;
using System.Collections.Generic;
using System.Web.Script.Serialization;
namespace nxcloud
{
public class NxCloud
{
// content urlencode !!! HttpUtility.UrlEncode
public static String send(String phone, String content, String appkey, String secretkey)
{
Encoding myEncoding = Encoding.GetEncoding("UTF-8");
string data = "appkey=" + appkey + "&secretkey=" + secretkey + "&phone=" + phone + "&content=" + content;
byte[] bytesToPost = System.Text.Encoding.Default.GetBytes(data);
string responseResult = String.Empty;
HttpWebRequest req = (HttpWebRequest)
HttpWebRequest.Create("http://api.nxcloud.com/api/sms/mtsend");
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
req.ContentLength = bytesToPost.Length;
using (Stream reqStream = req.GetRequestStream())
{
reqStream.Write(bytesToPost, 0, bytesToPost.Length);
}
HttpWebResponse cnblogsRespone = (HttpWebResponse)req.GetResponse();
if (cnblogsRespone != null && cnblogsRespone.StatusCode == HttpStatusCode.OK)
{
StreamReader sr;
using (sr = new StreamReader(cnblogsRespone.GetResponseStream()))
{
responseResult = sr.ReadToEnd();
}
sr.Close();
}
cnblogsRespone.Close();
JavaScriptSerializer serializer = new JavaScriptSerializer();
Dictionary<string, object> json = (Dictionary<string, object>)serializer.DeserializeObject(responseResult);
Console.WriteLine(responseResult);
return (String)json["messageid"];
}
public static void Main(string[] args)
{
NxCloud.send("", "", "", "");
Console.Read();
}
}
}
Introduction
- Send Message
- Mark Incoming Message as Read
- Upload Media File
- Get Media File
- Delete Media File
- Webhook
- Query Number Information
- Query Message Template
- Create Message Template
- Edit Message Template
- Delete Message Template
- Upload Template Example File
- Embedded Page Login
- Create Client Application
- List of Phone Numbers for Client Application
- Get Verification Code
- Verify Verification Code
- Create Local Client
Short message
Voice
Call Center(NXLink)
- Web Iframe
- Manual Dial Record
- Manual Dial Record Query By orderId
- List Agent Information
- List Agent Status
- List Queue
- List Agents In Queue
- List Agent Efficiency
- Update Queue Agents
- Create AutoDial Task
- Webhook - Manual Dial
Call Center(Callbot)
- Callbot API Summary
- Callbot API Authorization
- Callbot API Ping
- Create Auto Dial Task
- Add Contact List To Task
- Create Task And Add Contact
- Start Or Pause Task
- Update Task Parameters
- Get List Task
- List Call
- List Task Orders
- Stop Order
- Get Call Detail By Order
- Webhook - By Call
- Webhook - By Order
- Webhook - Task Status
Flash Call
Short links
邮件验证码
DID号码
通用
号码检测