示例#1
0
 /**
  * _dispatchRequest
  * 发起接口请求
  * @param  string $name      接口名
  * @param  array $arguments 接口参数
  * @return
  */
 protected function _dispatchRequest($name, $arguments)
 {
     $action = ucfirst($name);
     $params = array();
     if (is_array($arguments) && !empty($arguments)) {
         $params = (array) $arguments[0];
     }
     $params['Action'] = $action;
     if (!isset($params['Region'])) {
         $params['Region'] = $this->_defaultRegion;
     }
     require_once QCLOUDAPI_ROOT_PATH . '/Common/Request.php';
     $response = QcloudApi_Common_Request::send($params, $this->_secretId, $this->_secretKey, $this->_requestMethod, $this->_serverHost, $this->_serverUri);
     return $response;
 }
示例#2
0
 /**
  * _sendRequest
  * @param  string $url        请求url
  * @param  array  $paramArray 请求参数
  * @param  string $method     请求方法
  * @return
  */
 protected static function _sendRequest($url, $paramArray, $method = 'POST')
 {
     $ch = curl_init();
     if ($method == 'POST') {
         $paramArray = is_array($paramArray) ? http_build_query($paramArray) : $paramArray;
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $paramArray);
     } else {
         $url .= '?' . http_build_query($paramArray);
     }
     self::$_requestUrl = $url;
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     if (false !== strpos($url, "https")) {
         // 证书
         // curl_setopt($ch,CURLOPT_CAINFO,"ca.crt");
         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     }
     $resultStr = curl_exec($ch);
     self::$_rawResponse = $resultStr;
     $result = json_decode($resultStr, true);
     if (!$result) {
         return $resultStr;
     }
     return $result;
 }