Exemple #1
0
        /**
         * 创建一个腾讯云连接
         * @param action
         * @param apiAddr
         * @param urlArgs
         * @return 接口返回
         */
        private RestRequestAsyncHandle createTenAccess <T>(String action, String apiAddr, SortedDictionary <string, string> urlArgs, Action <IRestResponse <T> > callBackActoin) where T : new()
        {
            if (null == urlArgs)
            {
                urlArgs = new SortedDictionary <string, string>(StringComparer.Ordinal);
            }
            var nonce = RandomUtil.MakeSring(false, 6);

            PutUrlArg(urlArgs, "Action", action);
            PutUrlArg(urlArgs, "Timestamp", TimeUtil.CurrentMillis() / 1000 + "");
            PutUrlArg(urlArgs, "Nonce", nonce);
            PutUrlArg(urlArgs, "SecretId", mTenDnsApiSecret.SecretId);

            var signature = createSignature("POST", apiAddr, urlArgs);

            PutUrlArg(urlArgs, "Signature", signature);
            return(RequestUtil.AsyncRequest <T>(PROTOCOL + CNS_DOMAIN + apiAddr, urlArgs, callBackActoin, Method.POST));
            //restTemplate.getMessageConverters().add(new FastJsonHttpMessageConverter());
            //return restTemplate.postForObject(PROTOCOL + CNS_DOMAIN + apiAddr, convertMap(urlArgs), JSONObject.class);
        }