예제 #1
0
파일: BaseApi.cs 프로젝트: 24/CSDN.Client
        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;
                }
            }
        }
예제 #2
0
 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;
 }
예제 #3
0
        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);
        }
예제 #4
0
        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;
                }
            }
        }