Exemple #1
0
 /**
  * Sets the payload of the current JWS with an issued at value in the 'iat' property.
  *
  * @param array $payload
  *
  * @return $this
  */
 public function setPayload(array $payload)
 {
     if (!isset($payload['iat'])) {
         $payload['iat'] = time();
     }
     return parent::setPayload($payload);
 }
Exemple #2
0
 /**
  * Sets the payload of the current JWS with an issued at value in the 'iat' property.
  *
  * @param array $payload
  */
 public function setPayload(array $payload)
 {
     if (!isset($payload['iat'])) {
         $now = new \DateTime('now');
         $payload['iat'] = $now->format('U');
     }
     return parent::setPayload($payload);
 }
 /**
  * Делаем запрос.
  *
  * @param string $uri Адресс запроса
  * @param array  $req POST данные если есть
  * @param $method        Метод запроса (по умолчанию POST)
  *
  * @return mixed
  */
 public function request($uri, $req = array(), $method = HTTP_Request2::METHOD_POST)
 {
     $request = $this->initRequest($uri, $method);
     if ($method == HTTP_Request2::METHOD_POST) {
         $jws = new JWS(self::JWS_ALG, time());
         $jws->setPayload($req);
         $jws->sign($this->getPrivatekey());
         $req['request'] = $jws->getTokenString();
         $request->addPostParameter($req);
     }
     $this->last_request = $request;
     $this->sended = $request->send();
     if ($this->sended->getStatus() != 200) {
         $status = $this->sended->getStatus();
         ob_start();
         var_dump($req);
         $content = ob_get_clean();
         $this->log->writeln("FAIL Request({$status}):\nuri:{$uri}\n");
         $this->log->write("Request:\n " . $content);
         $this->log->write("Result:\n " . $this->sended->getBody());
     }
     return $this->sended;
 }