• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Message\Request类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Buzz\Message\Request的典型用法代码示例。如果您正苦于以下问题:PHP Request类的具体用法?PHP Request怎么用?PHP Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: bind

 /**
  * @param \Buzz\Message\Request $request
  * @param object                $tracking
  */
 public function bind(Request $request, $tracking)
 {
     $number = $tracking->getNumber();
     $trackingData = [];
     $trackingData = ['tracking_number' => $number];
     if ($courier = $tracking->getCourier()) {
         $trackingData['slug'] = $courier;
     }
     if ($orderId = $tracking->getOrderId()) {
         $trackingData['order_id'] = $orderId;
     }
     if ($orderUrl = $tracking->getOrderUrl()) {
         $trackingData['order_id_path'] = $orderUrl;
     }
     if ($meta = $tracking->getMeta()) {
         $customFields = [];
         foreach ($meta as $key => $value) {
             $customFields[$key] = $value;
         }
         $trackingData['custom_fields'] = $customFields;
     }
     $content = ['tracking' => $trackingData];
     $content = $this->encodeContent($content);
     $request->setContent($content);
 }
开发者ID:antimattr,项目名称:shipment-tracking,代码行数:29,代码来源:TrackingRequestHandler.php


示例2: bindCollection

 /**
  * @param  Buzz\Message\Request                           $request
  * @param  Doctrine\Common\Collections\Collection         $collection
  * @throws AntiMattr\Sears\Exception\IntegrationException
  */
 public function bindCollection(Request $request, Collection $collection)
 {
     $createdAt = $this->getCreatedAt();
     if (null === $createdAt) {
         throw new IntegrationException('CreatedAt is required');
     }
     $element = $this->xmlBuilder->setRoot('dss-order-adjustment-feed')->setNamespace('http://seller.marketplace.sears.com/oms/v1')->setSchemaLocation('http://seller.marketplace.sears.com/oms/v1 dss-order-return-v1.xsd ')->create();
     $element->addChild('date-time-stamp', $this->getCreatedAt()->format('Y-m-d\\TH:i:s'));
     // Hold all IntegrationExceptions until the end
     $exceptions = array();
     foreach ($collection as $orderReturn) {
         try {
             $this->xmlBuilder->addChild($element, 'dss-order-adjustment', $orderReturn->toArray());
         } catch (IntegrationException $e) {
             $orderId = $orderReturn->getPurchaseOrderId();
             $message = $e->getMessage();
             $exceptions[] = $this->exceptionMessageForOrder($orderId, $message);
         }
     }
     $xml = $element->asXML();
     $request->setContent($xml);
     if (count($exceptions) > 0) {
         throw new IntegrationException(json_encode($exceptions));
     }
 }
开发者ID:antimattr,项目名称:sears,代码行数:30,代码来源:OrderReturnRequestHandler.php


示例3: authenticate

 /**
  * Authenticate the request object. Apply the access_token to the URL
  *
  * TODO: implement
  * 
  * @param Request       $request        Request object to authenticate
  */
 public function authenticate(\Buzz\Message\Request $request)
 {
     $url = $request->getUrl();
     $prefix = strpos($url, '?') > 0 ? '&' : '?';
     $request->fromUrl($url . $prefix . 'access_token=' . $this->accessToken);
     return $request;
 }
开发者ID:puwenhan,项目名称:github-api3-php,代码行数:14,代码来源:OAuth.php


示例4: setCurlOptsFromRequest

 protected static function setCurlOptsFromRequest($curl, Message\Request $request)
 {
     curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $request->getMethod());
     curl_setopt($curl, CURLOPT_URL, $request->getUrl());
     curl_setopt($curl, CURLOPT_HTTPHEADER, $request->getHeaders());
     curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getContent());
 }
开发者ID:richardmiller,项目名称:Linktuesday.com,代码行数:7,代码来源:Curl.php


示例5: createRequest

 /**
  * Create request instance
  *
  * @param string $method Request method
  * @param string $path Request path
  * @param array $body Request body array
  */
 protected function createRequest($method, $path, array $body)
 {
     $request = new Request($method, $path, $this->createHost());
     $request->setHeaders(['Accept' => 'application/json; charset=UTF-8', 'Content-Type' => 'application/json', 'X-Stream' => 'true']);
     $request->addHeader('Authorization: Basic ' . base64_encode($this->options['username'] . ':' . $this->options['password']));
     $request->setContent(json_encode($body));
     return $request;
 }
开发者ID:endyjasmi,项目名称:neo4j,代码行数:15,代码来源:CurlDriver.php


示例6: createOffsitePurchase

 /**
  * @param array $paymentDetails
  *
  * @return \LedjIn\Bridge\Buzz\Response
  */
 public function createOffsitePurchase(array $paymentDetails)
 {
     $paymentDetails['TxType'] = static::OPERATION_PAYMENT;
     $query = http_build_query($paymentDetails);
     $request = new Request('post', $this->getOffsiteResource(), $this->getGatewayHost());
     $request->setContent($query);
     return $this->doRequest($request);
 }
开发者ID:ledjin,项目名称:sagepay,代码行数:13,代码来源:Api.php


示例7: testBearerAuthListener

 public function testBearerAuthListener()
 {
     $request = new Message\Request();
     $this->assertEmpty($request->getHeader('Authorization'));
     $listener = new BearerAuthListener('superSecretAccessTokenGeneratedByTheNsaItself');
     $listener->preSend($request);
     $this->assertEquals('Bearer superSecretAccessTokenGeneratedByTheNsaItself', $request->getHeader('Authorization'));
 }
开发者ID:dhensen,项目名称:buzz-additions,代码行数:8,代码来源:BearerAuthListenerTest.php


示例8: testBasicAuthHeader

 public function testBasicAuthHeader()
 {
     $request = new Message\Request();
     $this->assertEmpty($request->getHeader('Authorization'));
     $listener = new BasicAuthListener('foo', 'bar');
     $listener->preSend($request);
     $this->assertEquals('Basic ' . base64_encode('foo:bar'), $request->getHeader('Authorization'));
 }
开发者ID:ChazalFlorian,项目名称:enjoyPangolin,代码行数:8,代码来源:BasicAuthListenerTest.php


示例9: createHttpRequest

 /**
  * @return HttpRequest
  */
 public function createHttpRequest($method, $uri, $contentType = '', $acceptType = '')
 {
     $request = new HttpRequest($method, $uri, $this->httpHost);
     $request->addHeader('Authorization: Basic ' . base64_encode($this->httpAuth));
     $request->addHeader('Content-Type: ' . $this->generateMediaTypeString($contentType));
     $request->addHeader('Accept: ' . $this->generateMediaTypeString($acceptType));
     return $request;
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:11,代码来源:TestCase.php


示例10: processSetCookieHeaders

 /**
  * Processes Set-Cookie headers from a request/response pair.
  * 
  * @param Message\Request  $request  A request object
  * @param Message\Response $response A response object
  */
 public function processSetCookieHeaders(Message\Request $request, Message\Response $response)
 {
     foreach ($response->getHeader('Set-Cookie', false) as $header) {
         $cookie = new Cookie();
         $cookie->fromSetCookieHeader($header, parse_url($request->getHost(), PHP_URL_HOST));
         $this->addCookie($cookie);
     }
 }
开发者ID:philip,项目名称:Buzz,代码行数:14,代码来源:Jar.php


示例11: prepareRequest

 /**
  * @param  Request     $request
  * @return BuzzRequest
  */
 protected function prepareRequest(Request $request)
 {
     $buzzRequest = new BuzzRequest($request->getMethod(), $request->getUrl()->getResource(), $request->getUrl()->getHost());
     $buzzRequest->setProtocolVersion($request->getProtocolVersion());
     $buzzRequest->setHeaders(HeaderConverter::convertAssociativeToRaw($this->prepareHeaders($request)));
     $buzzRequest->setContent($request->getContent());
     return $buzzRequest;
 }
开发者ID:saxulum,项目名称:saxulum-http-client-adapter-buzz,代码行数:12,代码来源:HttpClient.php


示例12: testSendToInvalidUrl

 /**
  * @dataProvider provideInvalidHosts
  */
 public function testSendToInvalidUrl($host, $client)
 {
     $this->setExpectedException('Buzz\\Exception\\ClientException');
     $request = new Message\Request();
     $request->fromUrl('http://' . $host . ':12345');
     $response = new Message\Response();
     $client = new $client();
     $client->setTimeout(0.05);
     $client->send($request, $response);
 }
开发者ID:ChazalFlorian,项目名称:enjoyPangolin,代码行数:13,代码来源:ClientTest.php


示例13: __construct

 public function __construct(Response $response, Request $request, Curl $client)
 {
     $this->response = $response;
     $request->setProtocolVersion(1.1);
     $request->addHeader('Content-Type: application/json');
     $this->request = $request;
     $client->setTimeout(5);
     $client->setIgnoreErrors(true);
     $this->client = $client;
 }
开发者ID:expressly,项目名称:php-common,代码行数:10,代码来源:ExternalRoute.php


示例14: testSendToInvalidUrl

 /**
  * @dataProvider provideInvalidHosts
  */
 public function testSendToInvalidUrl($host)
 {
     $this->setExpectedException('RuntimeException');
     $request = new Message\Request();
     $request->fromUrl('http://' . $host . ':12345');
     $response = new Message\Response();
     $client = new FileGetContents();
     $client->setTimeout(0.05);
     $client->send($request, $response);
 }
开发者ID:kingsj,项目名称:core,代码行数:13,代码来源:FileGetContentsTest.php


示例15: isRequestCacheable

 /**
  *
  * @param \Buzz\Message\Request $request
  * @return boolean
  */
 public function isRequestCacheable(Request $request)
 {
     if (!$this->isHTTPMethodCacheable($request->getMethod())) {
         return false;
     }
     //[rfc2616-14.8]
     if ($request->getHeader("authorization")) {
         return false;
     }
     return true;
 }
开发者ID:ivoba,项目名称:buzzle,代码行数:16,代码来源:CacheValidator.php


示例16: request

 /**
  * Plumbery method to request webdriver server.
  *
  * @param string $verb    HTTP method to use (GET, POST, DELETE)
  * @param string $path    Relative URL to server, without prefix "/"
  * @param string $content Content of request
  * @param array  $headers Additional HTTP headers
  */
 public function request($verb, $path, $content = null, array $headers = array())
 {
     $url = $this->url . $path;
     $request = new Request($verb, $url);
     $request->setContent($content);
     $response = new Response();
     $this->client->send($request, $response);
     $response->setContent(str_replace("", "", $response->getContent()));
     $this->verifyResponse($response);
     return $response;
 }
开发者ID:alexandresalome,项目名称:php-webdriver,代码行数:19,代码来源:Client.php


示例17: testAuthenticate

 public function testAuthenticate()
 {
     $basic = new OAuth('KFGDSYGSDHKKGFSFN');
     // Create request, authenticate it
     $request = new Request();
     $request->fromUrl('http://test.com?name=dsyph3r');
     $request = $basic->authenticate($request);
     // Check access_token param is set correctly
     $url = parse_url($request->getUrl());
     $params = explode('&', $url['query']);
     $this->assertContains('access_token=KFGDSYGSDHKKGFSFN', $params);
 }
开发者ID:puwenhan,项目名称:github-api3-php,代码行数:12,代码来源:OAuthTest.php


示例18: send

 /**
  * Sends a request and records it to the journal.
  * 
  * @param Message\Request  $request  A request object
  * @param Message\Response $response A response object
  * 
  * @return Message\Response A response object
  */
 public function send(Message\Request $request, Message\Response $response = null)
 {
     if (null === $response) {
         $response = $this->createResponse();
     }
     if ($request instanceof BrowserAwareInterface) {
         $request->setBrowser($this);
     }
     $this->getClient()->send($request, $response);
     $this->getJournal()->record($request, $response);
     return $response;
 }
开发者ID:richardmiller,项目名称:Linktuesday.com,代码行数:20,代码来源:Browser.php


示例19: performRequest

 private function performRequest($endpoint, array $params = array())
 {
     $uri = static::BASE_URI . '/' . ltrim($endpoint, '/') . '?' . http_build_query($params);
     $request = new Request(Request::METHOD_GET, $uri);
     $request->addHeader(sprintf('Authorization: Bearer %s', $this->accessToken));
     $response = new Response();
     $this->client->send($request, $response);
     $content = $response->getContent();
     if ($response->getStatusCode() !== 200) {
         throw new InvalidArgumentException('An error occurred while calling the spotify API (' . $uri . '): ' . $content);
     }
     return json_decode($content, true);
 }
开发者ID:hansott,项目名称:spotify-backupper,代码行数:13,代码来源:ClientBuzz.php


示例20: testAddCookieHeadersAddsCookieHeaders

 public function testAddCookieHeadersAddsCookieHeaders()
 {
     $request = new Message\Request();
     $request->setHost('http://www.example.com');
     $cookie = new Cookie();
     $cookie->setName('SESSION');
     $cookie->setValue('asdf');
     $cookie->setAttribute(Cookie::ATTR_DOMAIN, '.example.com');
     $jar = new CookieJar();
     $jar->setCookies(array($cookie));
     $jar->addCookieHeaders($request);
     $this->assertEquals('SESSION=asdf', $request->getHeader('Cookie'));
 }
开发者ID:ChazalFlorian,项目名称:enjoyPangolin,代码行数:13,代码来源:CookieJarTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Message\Response类代码示例发布时间:2022-05-23
下一篇:
PHP Buzz\Browser类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap