c# 如何获取token,最好有demo
var pvars = new Dictionary
{
{"grant_type", "client_credentials"},
{"client_id", MTConfig.ClientId},
{"client_secret", MTConfig.ClientSecret},
};
HxTokenModel model = new HxTokenModel();
WebRequest request = HttpWebRequest.Create("https://a1.easemob.com/easemob-demo/chatdemoui/token");
JavaScriptSerializer serializer = new JavaScriptSerializer();
byte[] buf = System.Text.Encoding.GetEncoding("utf-8").GetBytes(serializer.Serialize(pvars));
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = buf.Length;
request.Method = "POST";
Stream RequestStream = request.GetRequestStream();
RequestStream.Close();
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));
string str = reader.ReadToEnd();
JavaScriptSerializer serializers = new JavaScriptSerializer();
model = serializers.Deserialize
reader.Close();
response.Close();
这样写问题在哪?
没有找到相关结果
已邀请:
1 个回复
[已注销]