Beispiel #1
0
        //同步http请求
        public string SyncRequest(
            Oauthkey2 oauthkey2,
            string url,
            string httpMethod,
            List <Parameter> listParam,
            List <Parameter> listFile)
        {
            Oauth oauth = new Oauth(oauthkey2);

            string queryString = null;
            string oauthUrl    = oauth.GetOauthUrl(
                url,
                oauthkey2.appKey,
                oauthkey2.appSecret,
                oauthkey2.tokenKey,
                oauthkey2.callbackUrl,
                listParam,
                out queryString);

            SyncHttp http = new SyncHttp();

            if (httpMethod == "GET")
            {
                return(http.HttpGet(oauthUrl, queryString));
            }
            else if ((listFile == null) || (listFile.Count == 0))
            {
                return(http.HttpPost(oauthUrl, queryString));
            }
            else
            {
                return(http.HttpPostWithFile(oauthUrl, queryString, listFile));
            }
        }
Beispiel #2
0
        //异步http请求
        public bool AsyncRequest(
            string url,
            string httpMethod,
            Oauthkey2 key,
            List <Parameter> listParam,
            List <Parameter> listFile,
            AsyncRequestCallback callback,
            out int callbkey)
        {
            Oauth oauth = null;

            oauth = new Oauth(key);

            string queryString = null;
            string oauthUrl    = oauth.GetOauthUrl(
                url,
                key.appKey,
                key.appSecret,
                key.tokenKey,
                key.callbackUrl,
                listParam,
                out queryString);

            AsyncHttp http = new AsyncHttp();

            callbkey = GetKey();
            CallbackInfo callbackInfo = new CallbackInfo();

            callbackInfo.key      = callbkey;
            callbackInfo.callback = callback;

            asyncRquestMap.Add(http, callbackInfo);

            bool bResult = false;

            if (httpMethod == "GET")
            {
                bResult = http.HttpGet(oauthUrl, queryString, new AsyncHttpCallback(HttpCallback));
            }
            else if ((listFile == null) || (listFile.Count == 0))
            {
                bResult = http.HttpPost(oauthUrl, queryString, new AsyncHttpCallback(HttpCallback));
            }
            else
            {
                bResult = http.HttpPostWithFile(oauthUrl, queryString, listFile, new AsyncHttpCallback(HttpCallback));
            }

            if (!bResult)
            {
                asyncRquestMap.Remove(http);
            }
            return(bResult);
        }
Beispiel #3
0
        //�첽http����
        public bool AsyncRequest(
            string url,
            string httpMethod,
            Oauthkey2 key,
            List<Parameter> listParam,
            List<Parameter> listFile,
            AsyncRequestCallback callback,
            out int callbkey)
        {
            Oauth oauth = null;

            oauth = new Oauth(key);

            string queryString = null;
            string oauthUrl = oauth.GetOauthUrl(
                url,
                key.appKey,
                key.appSecret,
                key.tokenKey,
                key.callbackUrl,
                listParam,
                out queryString);

            AsyncHttp http = new AsyncHttp();

            callbkey = GetKey();
            CallbackInfo callbackInfo = new CallbackInfo();
            callbackInfo.key = callbkey;
            callbackInfo.callback = callback;

            asyncRquestMap.Add(http, callbackInfo);

            bool bResult = false;

            if (httpMethod == "GET")
            {
                bResult = http.HttpGet(oauthUrl, queryString, new AsyncHttpCallback(HttpCallback));
            }
            else if ((listFile == null) || (listFile.Count == 0))
            {
                bResult = http.HttpPost(oauthUrl, queryString, new AsyncHttpCallback(HttpCallback));
            }
            else
            {
                bResult = http.HttpPostWithFile(oauthUrl, queryString, listFile, new AsyncHttpCallback(HttpCallback));
            }

            if (!bResult)
            {
                asyncRquestMap.Remove(http);
            }
            return bResult;
        }
        //ͬ��http����
        public string SyncRequest(string url, string httpMethod, OauthKey key, List<Parameter> listParam, List<Parameter> listFile)
        {
            Oauth oauth = new Oauth();

            string queryString = null;
            string oauthUrl = oauth.GetOauthUrl(url, httpMethod, key.customKey, key.customSecret,
                key.tokenKey, key.tokenSecret, key.verify, key.callbackUrl, listParam, out queryString);

            SyncHttp http = new SyncHttp();
            if (httpMethod == "GET")
            {
                return http.HttpGet(oauthUrl, queryString);
            }
            else if ((listFile == null) || (listFile.Count == 0))
            {
                return http.HttpPost(oauthUrl, queryString);
            }
            else
            {
                return http.HttpPostWithFile(oauthUrl, queryString, listFile);
            }
        }
        //同步http请求
        public string SyncRequest(string url, string httpMethod, OauthKey key, List <Parameter> listParam, List <Parameter> listFile)
        {
            Oauth oauth = new Oauth();

            string queryString = null;
            string oauthUrl    = oauth.GetOauthUrl(url, httpMethod, key.customKey, key.customSecret,
                                                   key.tokenKey, key.tokenSecret, key.verify, key.callbackUrl, listParam, out queryString);

            SyncHttp http = new SyncHttp();

            if (httpMethod == "GET")
            {
                return(http.HttpGet(oauthUrl, queryString));
            }
            else if ((listFile == null) || (listFile.Count == 0))
            {
                return(http.HttpPost(oauthUrl, queryString));
            }
            else
            {
                return(http.HttpPostWithFile(oauthUrl, queryString, listFile));
            }
        }
Beispiel #6
0
        //ͬ��http����
        public string SyncRequest(
            Oauthkey2 oauthkey2,
            string url,
            string httpMethod,
            List<Parameter> listParam,
            List<Parameter> listFile)
        {
            Oauth oauth = new Oauth(oauthkey2);

            string queryString = null;
            string oauthUrl = oauth.GetOauthUrl(
                url,
                oauthkey2.appKey,
                oauthkey2.appSecret,
                oauthkey2.tokenKey,
                oauthkey2.callbackUrl,
                listParam,
                out queryString);

            SyncHttp http = new SyncHttp();
            if (httpMethod == "GET")
            {
                return http.HttpGet(oauthUrl, queryString);
            }
            else if ((listFile == null) || (listFile.Count == 0))
            {
                return http.HttpPost(oauthUrl, queryString);
            }
            else
            {
                return http.HttpPostWithFile(oauthUrl, queryString, listFile);
            }
        }