Exemplo n.º 1
0
        /// <summary>
        /// GET数据
        /// </summary>
        /// <param name="requestUrl"></param>
        /// <param name="parameters"></param>
        /// <param name="callback"></param>
        protected virtual void GetData(string requestUrl, Parameters parameters, Action <string> callback)
        {
            this.LastError = null;
            var request = new AsyncHttpRequest(requestUrl, Charset)
            {
                Parameters = parameters
            };

            request.Get(EndGetResponseData, callback);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取授权Token
        /// </summary>
        /// <param name="requestUrl">API请求地址</param>
        /// <param name="parameters"></param>
        /// <param name="responseEnd"></param>
        /// <returns></returns>
        private void GetOAuthToken(string requestUrl, Parameters parameters, Action <string, Action <string> > responseEnd, Action <string> callback)
        {
            this.LastError = null;
            parameters.Add("oauth_consumer_key", this.AppKey);
            parameters.Add("oauth_signature_method", "HMAC-SHA1");
            parameters.Add("oauth_timestamp", Util.GenerateTimestamp());
            parameters.Add("oauth_nonce", Util.GenerateRndNonce());
            parameters.Add("oauth_version", "1.0");
            parameters.Add("oauth_signature", this.GenerateSignature("GET", requestUrl, parameters));
            string url = string.Concat(requestUrl, "?", parameters.BuildQueryString(true));

            var request = new AsyncHttpRequest(url, this.Charset);

            try
            {
                request.Get(responseEnd, callback);
            }
            catch (Exception ex)
            {
                this.LastError = ex;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///  获取IP地址,并回调
        /// </summary>
        /// <param name="callback"></param>
        public void GetIpAddress(Action <string> callback)
        {
            var request = new AsyncHttpRequest(IpaddressApi, Encoding.UTF8);

            request.Get(EndGetResponseData, callback);
        }