当前位置: 首页>>代码示例>>PHP>>正文


PHP RequestInterface::getUrl方法代码示例

本文整理汇总了PHP中Guzzle\Http\Message\RequestInterface::getUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestInterface::getUrl方法的具体用法?PHP RequestInterface::getUrl怎么用?PHP RequestInterface::getUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Guzzle\Http\Message\RequestInterface的用法示例。


在下文中一共展示了RequestInterface::getUrl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: factory

 /**
  * Simple exception factory for creating Intercom standardised exceptions
  *
  * @param RequestInterface $request The Request
  * @param Response $response The response
  * @return BadResponseException
  */
 public static function factory(RequestInterface $request, Response $response)
 {
     if (!static::isValidIntercomError($response->json())) {
         $label = 'Unsuccessful response';
         $class = __CLASS__;
     } elseif ($response->isClientError()) {
         $label = 'Client error response';
         $class = __NAMESPACE__ . '\\ClientErrorResponseException';
     } elseif ($response->isServerError()) {
         $label = 'Server error response';
         $class = __NAMESPACE__ . '\\ServerErrorResponseException';
     } else {
         $label = 'Unsuccessful response';
         $class = __CLASS__;
     }
     $message = $label . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[url] ' . $request->getUrl()));
     $e = new $class($message);
     $e->setResponse($response);
     $e->setRequest($request);
     // Sets the errors if the error response is the standard Intercom error type
     if (static::isValidIntercomError($response->json())) {
         $e->setErrors($response->json()['errors']);
     }
     return $e;
 }
开发者ID:atlir,项目名称:intercom-php,代码行数:32,代码来源:IntercomException.php

示例2: signRequest

 /**
  * {@inheritdoc}
  */
 public function signRequest(RequestInterface $request, CredentialsInterface $credentials)
 {
     // Refresh the cached timestamp
     $this->getTimestamp(true);
     // Add default headers
     $request->setHeader('x-amz-date', $this->getDateTime(DateFormat::RFC1123));
     // Add the security token if one is present
     if ($credentials->getSecurityToken()) {
         $request->setHeader('x-amz-security-token', $credentials->getSecurityToken());
     }
     // Grab the path and ensure that it is absolute
     $path = '/' . ltrim($request->getUrl(true)->normalizePath()->getPath(), '/');
     // Begin building the string to sign
     $sign = $request->getMethod() . "\n" . "{$path}\n" . $this->getCanonicalizedQueryString($request) . "\n";
     // Get all of the headers that must be signed (host and x-amz-*)
     $headers = $this->getHeadersToSign($request);
     foreach ($headers as $key => $value) {
         $sign .= $key . ':' . $value . "\n";
     }
     $sign .= "\n";
     // Add the body of the request if a body is present
     if ($request instanceof EntityEnclosingRequestInterface) {
         $sign .= (string) $request->getBody();
     }
     // Add the string to sign to the request for debugging purposes
     $request->getParams()->set('aws.string_to_sign', $sign);
     $signature = base64_encode(hash_hmac('sha256', hash('sha256', $sign, true), $credentials->getSecretKey(), true));
     // Add the authorization header to the request
     $request->setHeader('x-amzn-authorization', sprintf('AWS3 AWSAccessKeyId=%s,Algorithm=HmacSHA256,SignedHeaders=%s,Signature=%s', $credentials->getAccessKeyId(), implode(';', array_keys($headers)), $signature));
 }
开发者ID:congtrieu112,项目名称:anime,代码行数:33,代码来源:SignatureV3.php

示例3: factory

 /**
  * Simple exception factory for creating Intercom standardised exceptions
  *
  * @param RequestInterface $request The Request
  * @param Response $response The response
  * @return BadResponseException
  */
 public static function factory(RequestInterface $request, Response $response)
 {
     $response_json = $response->json();
     $intercom_unavailable_error = NULL;
     if (!static::isValidIntercomError($response_json)) {
         if ($response->isServerError()) {
             $label = 'Server error response';
             $class = __NAMESPACE__ . '\\ServerErrorResponseException';
             $intercom_unavailable_error = 'Service Unavailable: Back-end server is at capacity';
         } else {
             $label = 'Unsuccessful response';
             $class = __CLASS__;
         }
     } elseif ($response->isClientError()) {
         $label = 'Client error response';
         $class = __NAMESPACE__ . '\\ClientErrorResponseException';
     } elseif ($response->isServerError()) {
         $label = 'Server error response';
         $class = __NAMESPACE__ . '\\ServerErrorResponseException';
     } else {
         $label = 'Unsuccessful response';
         $class = __CLASS__;
     }
     $message = $label . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[url] ' . $request->getUrl()));
     $e = new $class($message);
     $e->setResponse($response);
     $e->setRequest($request);
     // Sets the errors if the error response is the standard Intercom error type
     if (static::isValidIntercomError($response_json)) {
         $e->setErrors($response_json['errors']);
     } elseif ($intercom_unavailable_error != NULL) {
         $e->setErrors(array('code' => 'service_unavailable', "message" => $intercom_unavailable_error));
     }
     return $e;
 }
开发者ID:scup,项目名称:intercom-php,代码行数:42,代码来源:IntercomException.php

示例4: onOpen

 /**
  * {@inheritdoc}
  * @throws \UnexpectedValueException If a controller is not \Ratchet\Http\HttpServerInterface
  */
 public function onOpen(ConnectionInterface $conn, RequestInterface $request = null)
 {
     if (null === $request) {
         throw new \UnexpectedValueException('$request can not be null');
     }
     $context = $this->_matcher->getContext();
     $context->setMethod($request->getMethod());
     $context->setHost($request->getHost());
     try {
         $route = $this->_matcher->match($request->getPath());
     } catch (MethodNotAllowedException $nae) {
         return $this->close($conn, 403);
     } catch (ResourceNotFoundException $nfe) {
         return $this->close($conn, 404);
     }
     if (is_string($route['_controller']) && class_exists($route['_controller'])) {
         $route['_controller'] = new $route['_controller']();
     }
     if (!$route['_controller'] instanceof HttpServerInterface) {
         throw new \UnexpectedValueException('All routes must implement Ratchet\\Http\\HttpServerInterface');
     }
     $parameters = $request->getUrl(true)->getQuery()->toArray();
     foreach ($route as $key => $value) {
         if (is_string($key) && '_' !== substr($key, 0, 1)) {
             $parameters[$key] = $value;
         }
     }
     $url = Url::factory($request->getPath());
     $url->setQuery($parameters);
     $request->setUrl($url);
     $conn->controller = $route['_controller'];
     $conn->controller->onOpen($conn, $request);
 }
开发者ID:Rudi9719,项目名称:stein-syn,代码行数:37,代码来源:Router.php

示例5: __construct

 public function __construct(ConnectionInterface $conn)
 {
     if (isset($conn->WebSocket)) {
         $this->request = $conn->WebSocket->request;
         $this->query = $this->request->getUrl(true)->getQuery();
     }
     if (isset($conn->Session)) {
         $this->session = $conn->Session;
     }
     $sessionName = ini_get('session.name');
     if (isset($this->request) && isset($this->request->getCookies()[$sessionName])) {
         $this->id = $this->request->getCookies()[$sessionName];
     } elseif (isset($conn->resourceId)) {
         $this->id = $conn->resourceId;
     }
     $this->parameters = new ParameterBag();
 }
开发者ID:sulu,项目名称:sulu,代码行数:17,代码来源:ConnectionContext.php

示例6: factory

 /**
  * Factory method to create a new Oauth exception.
  *
  * @param RequestInterface $request
  * @param Response $response
  *
  * @return OauthException
  */
 public static function factory(RequestInterface $request, Response $response)
 {
     $message = 'Client error response' . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[url] ' . $request->getUrl()));
     $e = new static($message);
     $e->setResponse($response);
     $e->setRequest($request);
     return $e;
 }
开发者ID:cpliakas,项目名称:magento-client-php,代码行数:16,代码来源:OauthException.php

示例7: checkError

 /**
  * Check the response for an error.
  *
  * @param Response         $response The response received.
  *
  * @param RequestInterface $request  The request sent.
  *
  * @return void
  *
  * @throws \RuntimeException On any error.
  */
 protected function checkError(Response $response, RequestInterface $request)
 {
     if ($response->getStatusCode() == 200 || $response->getStatusCode() == 201) {
         return;
     }
     switch ($response->getHeader('Content-Type')) {
         case 'text/plain':
             throw new \RuntimeException('Error: ' . $response->getBody(true) . ' URI: ' . $request->getUrl());
         case 'application/json':
             $error = json_decode($response->getBody(true));
             if (isset($error->message)) {
                 throw new \RuntimeException($error->message . ' URI: ' . $request->getUrl());
             }
             break;
         default:
             throw new \RuntimeException('Unknown Error: No error message was returned from the server - Code: ' . $response->getStatusCode() . ' URI: ' . $response->getRequest()->getUrl());
     }
 }
开发者ID:cyberspectrum,项目名称:contao-toolbox,代码行数:29,代码来源:Transport.php

示例8: cloneRequestWithMethod

 public function cloneRequestWithMethod(RequestInterface $request, $method)
 {
     if ($request->getClient()) {
         $cloned = $request->getClient()->createRequest($method, $request->getUrl(), $request->getHeaders());
     } else {
         $cloned = $this->create($method, $request->getUrl(), $request->getHeaders());
     }
     $cloned->getCurlOptions()->replace($request->getCurlOptions()->toArray());
     $cloned->setEventDispatcher(clone $request->getEventDispatcher());
     if (!$cloned instanceof EntityEnclosingRequestInterface) {
         $cloned->removeHeader('Content-Length');
     } elseif ($request instanceof EntityEnclosingRequestInterface) {
         $cloned->setBody($request->getBody());
     }
     $cloned->getParams()->replace($request->getParams()->toArray());
     $cloned->dispatch('request.clone', array('request' => $cloned));
     return $cloned;
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:18,代码来源:RequestFactory.php

示例9: setUrl

 protected function setUrl(RequestInterface $request)
 {
     $this->url = $request->getUrl(true);
     if ($request->getUsername()) {
         $this->url->setUsername($request->getUsername());
     }
     if ($request->getPassword()) {
         $this->url->setPassword($request->getPassword());
     }
 }
开发者ID:Ryu0621,项目名称:SaNaVi,代码行数:10,代码来源:PhpStreamRequestFactory.php

示例10: factory

 public static function factory(RequestInterface $request, Response $response)
 {
     $label = 'Bearer error response';
     $bearerReason = self::headerToReason($response->getHeader("WWW-Authenticate"));
     $message = $label . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[bearer reason] ' . $bearerReason, '[url] ' . $request->getUrl()));
     $e = new static($message);
     $e->setResponse($response);
     $e->setRequest($request);
     $e->setBearerReason($bearerReason);
     return $e;
 }
开发者ID:Farik2605,项目名称:tobi,代码行数:11,代码来源:BearerErrorResponseException.php

示例11: match

 public function match(RequestInterface $request)
 {
     if ($request->getMethod() !== $this->method) {
         return null;
     }
     foreach ($this->responses as $uri => $response) {
         if (preg_match('~' . $uri . '~', $request->getUrl()) > 0) {
             return $response;
         }
     }
     return null;
 }
开发者ID:thewilkybarkid,项目名称:guzzle-mock-matcher,代码行数:12,代码来源:UriRequestMatcher.php

示例12: __construct

 public function __construct(RequestInterface $request)
 {
     $url = Url::factory($request->getUrl());
     $url->setUsername($request->getUsername());
     $url->setPassword($request->getPassword());
     $this->url = $url;
     $this->request = $request;
     $this->finalRequest = array();
     $this->method = 'POST';
     $this->iterationNumber = 0;
     $this->blobList = null;
     $this->NXVoidOperation = 'true';
 }
开发者ID:nuxeo,项目名称:nuxeo-automation-php-client,代码行数:13,代码来源:NuxeoRequest.php

示例13: factory

 /**
  * Factory method to create a new response exception based on the response code.
  *
  * @param RequestInterface $request  Request
  * @param Response         $response Response received
  * @param string           $label
  *
  * @return BadResponseException
  */
 public static function factory(RequestInterface $request, Response $response, $label = null)
 {
     if (!$label) {
         if ($response->isClientError()) {
             $label = 'Client error response';
         } elseif ($response->isServerError()) {
             $label = 'Server error response';
         } else {
             $label = 'Unsuccessful response';
         }
     }
     $message = $label . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[url] ' . $request->getUrl(), '[content type] ' . $response->getContentType(), '[response body] ' . $response->getBody(true)));
     $result = new static($message);
     $result->setResponse($response);
     $result->setRequest($request);
     return $result;
 }
开发者ID:aculvi,项目名称:OroCRMMailChimpBundle,代码行数:26,代码来源:BadResponseException.php

示例14: factory

 public static function factory(RequestInterface $request, Response $response)
 {
     if ($response->isClientError()) {
         $label = 'Client error response';
         $class = __NAMESPACE__ . '\\ClientErrorResponseException';
     } elseif ($response->isServerError()) {
         $label = 'Server error response';
         $class = __NAMESPACE__ . '\\ServerErrorResponseException';
     } else {
         $label = 'Unsuccessful response';
         $class = __CLASS__;
     }
     $message = $label . PHP_EOL . implode(PHP_EOL, array('[status code] ' . $response->getStatusCode(), '[reason phrase] ' . $response->getReasonPhrase(), '[url] ' . $request->getUrl()));
     $e = new self($message);
     $e->setResponse($response);
     $e->setRequest($request);
     return $e;
 }
开发者ID:karllhughes,项目名称:clearbit-php,代码行数:18,代码来源:BadResponseException.php

示例15: __toString

 /**
  * Returns an HTML-formatted string representation of the exception.
  *
  * @return string
  * @internal
  */
 public function __toString()
 {
     $msg = $this->getMessage();
     if (is_object($this->requestObj) && $this->requestObj instanceof \Guzzle\Http\Message\Request) {
         $request = array('url' => $this->requestObj->getUrl(), 'host' => $this->requestObj->getHost(), 'headers' => $this->requestObj->getRawHeaders(), 'query' => (string) $this->requestObj->getQuery());
         if ($this->requestObj instanceof \Guzzle\Http\Message\EntityEnclosingRequestInterface) {
             $request_body = $this->requestObj->getBody();
             $request['content-type'] = $request_body->getContentType();
             $request['content-length'] = $request_body->getContentLength();
             $request['body'] = $request_body->__toString();
         }
         $msg .= "\n\nRequest: <pre>" . htmlspecialchars(print_r($request, true)) . '</pre>';
     }
     if (is_object($this->responseObj) && $this->responseObj instanceof \Guzzle\Http\Message\Response) {
         $response = array('status' => $this->responseObj->getStatusCode(), 'headers' => $this->responseObj->getRawHeaders(), 'body' => $this->responseBody);
         $msg .= "\n\nResponse: <pre>" . htmlspecialchars(print_r($response, true)) . '</pre>';
     }
     return $msg;
 }
开发者ID:nevetS,项目名称:flame,代码行数:25,代码来源:ResponseException.php


注:本文中的Guzzle\Http\Message\RequestInterface::getUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。