コード例 #1
0
 /**
  * \brief Tokenエンドポイントリソース取得メソッド
  */
 public function fetchToken()
 {
     $httpClient = new HttpClient();
     $httpClient->setHeader(array("Expect:", "Authorization: Basic " . $this->cred->toAuthorizationHeader()));
     $httpClient->requestPost($this->url, $this->params);
     $this->res_body = $httpClient->getResponseBody();
 }
コード例 #2
0
 /**
  * \brief APIエンドポイントリソース取得メソッド
  * @param	$url	APIエンドポイント
  * @param	$method	HTTPリクエストメソッド
  * @throws  UnexpectedValueException
  */
 protected function fetchResource($url, $method)
 {
     $httpClient = new HttpClient();
     $httpClient->setHeader(array($this->token->__toString()));
     switch ($method) {
         case 'GET':
             $httpClient->requestGet($url, $this->params);
             break;
         case 'POST':
             $httpClient->requestPost($url, $this->params);
             // supported safe data RFC3986
             if (is_array($this->params)) {
                 foreach ($this->params as $key => $value) {
                     $this->params[$key] = rawurlencode(rawurldecode($value));
                 }
             }
             break;
         case 'PUT':
             $httpClient->requestPut($url, $this->params);
             break;
         case 'DELETE':
             $httpClient->requestDelete($url, $this->params);
             break;
         default:
             throw new \UnexpectedValueException('unsupported http method');
     }
     $res_error_header = $httpClient->getResponseHeader('WWW-Authenticate');
     $this->_checkAuthorizationError($res_error_header);
     $this->res_body = $httpClient->getResponseBody();
 }
コード例 #3
0
 /**
  * \brief SSL証明書チェック解除メソッド
  *
  */
 public function disableSSLCheck()
 {
     HttpClient::disableSSLCheck();
 }