示例#1
0
 /**
  * @param $url
  * @param array $params
  * @param $gzip
  * @return mixed|null
  * @throws RequestException
  */
 public static function httpPostJson($url, $params = [], $gzip = false)
 {
     if (!array_key_exists('version', $params)) {
         $params['version'] = GTConfig::getSDKVersion();
     }
     $action = $params['action'];
     $data = json_encode($params);
     $result = null;
     try {
         $resp = HttpManager::httpPost($url, $data, $gzip, $action);
         LogUtils::debug('发送请求 post:{$data} return:{$resp}');
         $result = json_decode($resp, true);
         return $result;
     } catch (\Exception $e) {
         throw new RequestException($params['requestId'], 'httpPost:[' . $url . '] [' . $data . ' ] [ ' . $result . ']:', $e);
     }
 }
示例#2
0
 public static function httpPostJson($url, $params, $gzip)
 {
     if (is_null($params["version"])) {
         $params["version"] = GTConfig::getSDKVersion();
     }
     $action = $params["action"];
     $data = json_encode($params);
     $result = null;
     try {
         $resp = HttpManager::httpPost($url, $data, $gzip, $action);
         LogUtils::debug("发送请求 post:{$data} return:{$resp}");
         $result = json_decode($resp, true);
         return $result;
     } catch (Exception $e) {
         throw new RequestException($params["requestId"], "httpPost:[" . $url . "] [" . $data . " ] [ " . $result . "]:", $e);
     }
 }