有没有调用JSAPI的代码案例
Re有没有调用JSAPI的代码案例
C# code
public static string getss()
{
WebRequest wrep = WebRequest.Create('https://oapi.dingtalk.com/gettoken?corpid=id&corpsecret=secret');
WebResponse wrp = wrep.GetResponse();
Stream strm = wrp.GetResponseStream();
StreamReader sr = new StreamReader(strm, Encoding.UTF8);
string jsonstr= sr.ReadToEnd();
sr.Close();
return jsonstr;// {'access_token':'value','errcode':0,'errmsg':'ok'}
}亲测有用
-------------------------
Re有没有调用JSAPI的代码案例
发送消息,亲测有用
public string Send()
{
HttpWebRequest request = WebRequest.Create('https://oapi.dingtalk.com/message/send?access_token=access_token') as HttpWebRequest;
//'{\'errcode\':40035,\'errmsg\':\'不合法的参数\'}'
string ps = '{\'touser\':\'16|824\',\'toparty\':\'1\',\'agentid\':\'3917947\',\'msgtype\':\'text\',\'text\':{\'content\':\'this is a test memo four.\'}}';
request.Method = 'POST';
request.ContentType = 'application/json';
request.ContentLength = Encoding.UTF8.GetByteCount(ps);
Stream strs = request.GetRequestStream();
StreamWriter strw = new StreamWriter(strs,Encoding.GetEncoding('GB2312'));
strw.Write(ps);
strw.Close();
HttpWebResponse reponse = request.GetResponse() as HttpWebResponse;
Stream sts = reponse.GetResponseStream();
StreamReader sr = new StreamReader(sts,Encoding.GetEncoding('UTF-8'));
string s = sr.ReadToEnd();
sr.Close();
sts.Close();
return s;
}
赞0
踩0