示例#1
0
 public Form1()
 {
     InitializeComponent();
     Scaler.Http http = new Scaler.Http();
     IP            = http.GetHTML("http://oa.sdhuijiu.com/ip.aspx", "", "", "", "GET");
     lbListen.Text = IP + ":8205";
 }
示例#2
0
        public string sign(object stu_id)
        {
            string url = string.Format("http://xuanke.juntaijishu.com/index/lock_test.aspx?b_id=7&s_id={0}&l_id=261&d=fri", stu_id);

            Scaler.Http http = new Scaler.Http();
            http.KeepAlive = false;
            //http.Proxy = "127.0.0.1"; http.ProxyPort = "8888";

            string content = http.GetHTML(url, "", "", "", "GET");

            Scaler.Win.WriteLog(stu_id + "\t" + content);
            Interlocked.Decrement(ref iwork);
            return("");
        }
示例#3
0
        public string getAccessToken()
        {
            if (!string.IsNullOrEmpty(AccessToken) && DateTime.Now < dtExpire)
            {
                return(AccessToken);
            }
            string url = string.Format("https://openapi.baidu.com/oauth/2.0/token?grant_type=client_credentials&client_id={0}&client_secret={1}", app_key, secret_key);

            Scaler.Http http    = new Scaler.Http();
            string      content = http.GetHTML(url, "", "", "", "GET");

            Newtonsoft.Json.Linq.JObject obj;
            try
            {
                obj = Newtonsoft.Json.Linq.JObject.Parse(content);
            }
            catch (Exception err)
            {
                Scaler.Win.WriteLog("获取Access失败!|" + content + "|" + err.Message);
                return(string.Empty);
            }

            /*{
             *  "access_token": "1.a6b7dbd428f731035f771b8d********.86400.1292922000-2346678-124328",
             *  "expires_in": 2592000,
             *  "refresh_token": "2.385d55f8615fdfd9edb7c4b********.604800.1293440400-2346678-124328",
             *  "scope": "public audio_tts_post ...",
             *  "session_key": "ANXxSNjwQDugf8615Onqeik********CdlLxn",
             *  "session_secret": "248APxvxjCZ0VEC********aK4oZExMB",
             * }*/
            if (!obj.TryGetValue("access_token", out Newtonsoft.Json.Linq.JToken access_token))
            {
                Scaler.Win.WriteLog("获取Access失败!无access_token|" + content);
                return(string.Empty);
            }
            AccessToken = access_token.ToString();
            if (obj.TryGetValue("expires_in", out access_token))
            {
                if (int.TryParse(access_token.ToString(), out int expires))
                {
                    dtExpire = DateTime.Now.AddHours(-1).AddSeconds(expires);
                }
            }
            return(AccessToken);
        }