public static NGAccessToken GetAccess_token() { string appid = NGWeiXinConfig.appID; string secret = NGWeiXinConfig.appsecret; string strUrl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + appid + "&secret=" + secret; NGAccessToken mode = new NGAccessToken(); HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(strUrl); req.Method = "GET"; using (WebResponse wr = req.GetResponse()) { HttpWebResponse myResponse = (HttpWebResponse)req.GetResponse(); StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8); string content = reader.ReadToEnd(); Log.Debug("NGAccessTokenTools", "GetAccess_token response : " + content); //Response.Write(content); //在这里对Access_token 赋值 NGAccessToken token = new NGAccessToken(); token = NGJSONHelper.ParseFromJson <NGAccessToken>(content); mode.access_token = token.access_token; mode.expires_in = token.expires_in; } return(mode); }
public static string ToJGGridJson(string curPage, string totalPage, string totalRecords, DataTable dt, string[] fields, string keyField) { //{ //"page":"2", //"total":2, //"records":"13", //"rows":[ //{"id":"3","cell":["3","2007-10-02","Client 2","300.00","60.00","360.00","note invoice 3 & and amp test"]}, //{"id":"2","cell":["2","2007-10-03","Client 1","200.00","40.00","240.00","note 2"]}, //{"id":"1","cell":["1","2007-10-01","Client 1","100.00","20.00","120.00","note 1"]} //], //"userdata":{"amount":600,"tax":120,"total":720,"name":"Totals:"} //} string s = "{"; s += "\"page\":\"" + curPage + "\","; s += "\"total\":" + totalPage + ","; s += "\"records\":\"" + totalRecords + "\","; s += "\"rows\":["; s += NGJSONHelper.GetJGGridRows(dt, fields, keyField); s += "],"; s += "\"userdata\":{}"; s += "}"; return(s); }
public static NGJSApiTicket GetJSApi_Ticket() { string access_token = NGAccessTokenTools.GetExistAccess_Token(); string strUrl = "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=" + access_token + "&type=jsapi"; NGJSApiTicket mode = new NGJSApiTicket(); HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(strUrl); req.Method = "GET"; using (WebResponse wr = req.GetResponse()) { HttpWebResponse myResponse = (HttpWebResponse)req.GetResponse(); StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8); string content = reader.ReadToEnd(); Log.Debug("NGJSApiTicketTools", "GetJSApi_Ticket response : " + content); //Response.Write(content); //在这里对SApiTicket 赋值 NGJSApiTicket token = new NGJSApiTicket(); token = NGJSONHelper.ParseFromJson <NGJSApiTicket>(content); mode.ticket = token.ticket; mode.expires_in = token.expires_in; } return(mode); }