コード例 #1
0
 /**
  * {@inheritDoc}
  */
 public function getIncomingStream()
 {
     $options = stream_context_get_options($this->context);
     $method = 'GET';
     if (isset($options['http']['method'])) {
         $method = $options['http']['method'];
     }
     $headers = [];
     if (isset($options['http']['header'])) {
         $headerLines = explode("\r\n", $options['http']['header']);
         foreach ($headerLines as $headerLine) {
             list($header, $value) = explode(': ', $headerLine, 2);
             $headers[$header][] = $value;
         }
     }
     $body = null;
     if (isset($options['http']['content'])) {
         $body = $options['http']['content'];
     }
     $protocolVersion = 1.1;
     if (isset($options['http']['protocol_version'])) {
         $protocolVersion = $options['http']['protocol_version'];
     }
     $request = new Request($method, $this->path, $headers, $body, $protocolVersion);
     return \GuzzleHttp\Psr7\stream_for(\GuzzleHttp\Psr7\str($request));
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function __invoke(StreamInterface $stream)
 {
     $request = \GuzzleHttp\Psr7\parse_request($stream->getContents());
     $response = $this->run($request);
     if ($this->getAssertionCallback()) {
         call_user_func($this->getAssertionCallback(), $request);
     }
     return \GuzzleHttp\Psr7\stream_for(\GuzzleHttp\Psr7\str($response));
 }
コード例 #3
0
 /**
  * @param $method
  * @param $uri
  * @param array $data
  * @return mixed|\Psr\Http\Message\ResponseInterface
  * @throws MailChimpAuthNotSet
  * @throws MailChimpException
  */
 protected function process($method, $uri, $data = [])
 {
     if (!$this->auth || !$this->endpoint) {
         throw new MailChimpAuthNotSet();
     }
     try {
         return $this->guzzle->request($method, $this->endpoint . $uri, array_merge($this->auth, $data));
     } catch (RequestException $e) {
         $message = $e->hasResponse() ? ' due to ' . \GuzzleHttp\Psr7\str($e->getResponse()) : '[No MailChimp Message]';
         throw new MailChimpException('Error: ' . $method . 'ing to ' . $this->endpoint . $uri . ' due to ' . $message);
     }
 }
コード例 #4
0
ファイル: User.php プロジェクト: e-ReColNat/recolnat-diff
 /**
  * Grab data through webservice
  */
 private function setData()
 {
     try {
         $client = new Client(['base_uri' => $this->apiRecolnatBaseUri]);
         $response = $client->request('GET', $this->apiRecolnatUserPath . urlencode($this->getUsername()));
         $this->data = \GuzzleHttp\json_decode($response->getBody()->getContents());
     } catch (ClientException $e) {
         echo \GuzzleHttp\Psr7\str($e->getRequest());
         echo \GuzzleHttp\Psr7\str($e->getResponse());
     }
 }