コード例 #1
0
ファイル: AppTicket.cs プロジェクト: kangwl/BootstrapWeb
 public string GetAccessTokenJson(string appID, string appSecret)
 {
     string reqUrl = string.Format(GetAccessTokenUrl(appID, appSecret));
        HttpWebHelper httpWebHelper = new HttpWebHelper(reqUrl);
        string json = httpWebHelper.GetResponseStr();
        return json;
 }
コード例 #2
0
ファイル: AppTicket.cs プロジェクト: kangwl/BootstrapWeb
 public string GetAccessTokenJson()
 {
     string reqUrl = string.Format(GetAccessTokenUrl(AppConfig.Instance.AppID, AppConfig.Instance.AppSecret));
        HttpWebHelper httpWebHelper = new HttpWebHelper(reqUrl);
        string json = httpWebHelper.GetResponseStr();
        return json;
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: kangwl/BootstrapWeb
        private static void Main(string[] args)
        {
            //TestM testM = new TestM();
            //Console.WriteLine(testM.GetResult("3"));
            //Console.WriteLine(testM.GetResultBridge("3"));
            //Console.WriteLine("end");
            //Console.Read();

            //                 string xmlSend = @"<xml>
            //                            <ToUserName><![CDATA[123]]></ToUserName>
            //                            <FromUserName><![CDATA[2]]></FromUserName>
            //                            <CreateTime>123</CreateTime>
            //                            <MsgType><![CDATA[text]]></MsgType>
            //                            <Content><![CDATA[333]]></Content>
            //                            </xml>";
            //            XmlDocument xmldoc = new XmlDocument();
            //            xmldoc.LoadXml(xmlSend);
            //            string a = XK.Common.XmlHelper.GetXmlNodeTextByXpath(xmldoc, "//ToUserName");
            //            Console.WriteLine(a);
            //            Console.WriteLine("end");
            //            Console.Read();
            //XK.Common.web.HttpWebHelper webHelper = new HttpWebHelper("http://d.10jqka.com.cn/v2/realhead/hs_600372/last.js");
            //string res = webHelper.GetResponseStr();
            //int firstIndex = res.IndexOf('{');
            //string s = res.Substring(firstIndex).TrimEnd(')');

            //JObject jo = (JObject)JsonConvert.DeserializeObject(s);
            //string zone = jo["items"]["7"].ToString();
            //Newtonsoft.Json.JsonReader reader=new JTokenReader();

            string reqBase = "http://news.10jqka.com.cn/public/index_keyboard_{0}_stock,hk,usa_5_jsonp.html";
            string reqUrl = string.Format(reqBase, "zh");
            XK.Common.web.HttpWebHelper webHelper = new HttpWebHelper(reqUrl);
            string res = HttpUtility.UrlDecode(webHelper.GetResponseStr());
            int firstIndex = res.IndexOf('[');
            string s = res.Substring(firstIndex).TrimEnd(')');
            var a = s.Substring(1);
            var aa = a.Substring(0, a.Length - 1);
            var aa1 = aa.Substring(1);
            var aindex = aa1.IndexOf(']');
            var aa2 = aa1.Substring(0, aindex);
            var rarr = aa2.Split(',');
            List<string> stocks = new List<string>();
            foreach (string s1 in rarr) {
                var sArr = s1.Split(' ');
                string code = sArr[0];
                string name = sArr[1]  ;

                string outStr = "";
                if (!string.IsNullOrEmpty(name)) {
                    string[] strlist = name.Replace("\\", "").Split('u');
                    try {
                        for (int i = 1; i < strlist.Length; i++) {
                            //将unicode字符转为10进制整数,然后转为char中文字符
                            outStr += (char)int.Parse(strlist[i], System.Globalization.NumberStyles.HexNumber);
                        }
                    }
                    catch (FormatException ex) {
                        outStr = ex.Message;
                    }
                }
                stocks.Add(code + " " + outStr);
            }
            Console.WriteLine(string.Join("\n", stocks));
              //  Console.WriteLine("\u4e2d\u822a\u7535\u5b50");
            Console.Read();
        }