C#/.Net发送Websocket消息 - GoEasy PubSub

本节内容为C#实现GoEasy Rest接口发送消息, 使用时,可参阅Rest接口的详细介绍

C#

string postDataStr = "appkey=BC-xxxxxxxxx&channel=demo_channel&content=Hello";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http(s)://<REST Host>/publish");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
request.ContentLength = Encoding.UTF8.GetByteCount(postDataStr);
Stream myRequestStream = request.GetRequestStream();
byte[] data = Encoding.UTF8.GetBytes(postDataStr);
myRequestStream.Write(data, 0, data.Length);

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream myResponseStream = response.GetResponseStream();
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
string retString = myStreamReader.ReadToEnd();
myStreamReader.Close();
myResponseStream.Close();

REST Host

杭州: rest-hangzhou.goeasy.io
新加坡: rest-singapore.goeasy.io

results matching ""

    No results matching ""