public BaseApi(string accessToken, string appKey) { access_token = accessToken; app_key = appKey; var curr = System.Web.HttpContext.Current; if (curr != null) { clientIP = curr.Request.UserHostAddress; } else { try { SocketHelper socket = new SocketHelper(new Uri("http://iframe.ip138.com/ic.asp")); string html = socket.Get(true); clientIP = new Regex(@"\[([\d.]+?)\]").Match(html).Groups[1].Value; } catch { clientIP = string.Empty; } } }
private AccessToken GetAccessToken(string uri) { SocketHelper socket = new SocketHelper(new Uri(uri)); string json = socket.Get(true); string[] kvs = json.Split(','); var acc = new AccessToken() { Token = kvs[0].Split(':')[1].Trim('"'), Expires = kvs[1].Split(':')[1].ToInt(), UID = kvs[2].Split(':')[1].TrimEnd('}').ToInt() }; return acc; }
private AccessToken GetAccessToken(string uri) { SocketHelper socket = new SocketHelper(new Uri(uri)); string json = socket.Get(true); string[] kvs = json.Split(','); var acc = new AccessToken() { Token = kvs[0].Split(':')[1].Trim('"'), Expires = kvs[1].Split(':')[1].ToInt(), UID = kvs[2].Split(':')[1].TrimEnd('}').ToInt() }; return(acc); }