import clr
clr.AddReference("System")
clr.AddReference("System.Web.Extensions")
clr.AddReference("Kingdee.BOS.Core")
clr.AddReference("Kingdee.BOS")
clr.AddReference("Newtonsoft.Json")
import sys
from System import *
from System.Collections.Generic import *
from System.Threading import *
from System.IO import *
from System.Net import *
from System.Text import *
from System.Security.Cryptography import *
from System.Web.Script.Serialization import *
from System.Collections.Generic import Dictionary
from Newtonsoft.Json.Linq import *
reload(sys)
sys.setdefaultencoding('utf-8')
def ButtonClick(e):
#发送get请求
#webRequest=get("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=XXX&corpsecret=XXX")
#this.View.ShowMessage(webRequest)
#解析json
#JObject = JObject.Parse(webRequest)
#this.View.ShowMessage(JObject['access_token'].ToString())
#发送post请求
#webRequest=post('https://www.anyan.com/anyan/12223.php','choose=asdfga')
#this.View.ShowMessage(webRequest)
#发送post请求
#webRequest=post('https://www.anyan.com/anyan/22222.php','choose={"id":"123"}')
#this.View.ShowMessage(webRequest)
def get(url):
webRequest = WebRequest.Create(url)
webRequest.Method = "GET";
webResponse = webRequest.GetResponse();
stream = webResponse.GetResponseStream();
streamReader =StreamReader(stream, Encoding.GetEncoding("utf-8"));
result = streamReader.ReadToEnd();
return result
def post(url,postdata):
webRequest = HttpWebRequest.Create(url);
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
data=Encoding.ASCII.GetBytes(postdata);
webRequest.ContentLength = data.Length;
webRequest.GetRequestStream().Write(data, 0, data.Length);
webRequest.GetRequestStream().Flush();
webRequest.GetRequestStream().Close();
webResponse =webRequest.GetResponse();
streamReader =StreamReader( webResponse .GetResponseStream(),Encoding.GetEncoding("utf-8") );
result=streamReader.ReadToEnd()
return result