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


PHP Request::setContent方法代码示例

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


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

示例4: 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

示例5: 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

示例6: createRequest

 /**
  * Converts a PSR request into a BuzzRequest request.
  *
  * @param RequestInterface $request
  *
  * @return BuzzRequest
  */
 private function createRequest(RequestInterface $request)
 {
     $buzzRequest = new BuzzRequest();
     $buzzRequest->setMethod($request->getMethod());
     $buzzRequest->fromUrl($request->getUri()->__toString());
     $buzzRequest->setProtocolVersion($request->getProtocolVersion());
     $buzzRequest->setContent((string) $request->getBody());
     $this->addPsrHeadersToBuzzRequest($request, $buzzRequest);
     return $buzzRequest;
 }
开发者ID:php-http,项目名称:buzz-adapter,代码行数:17,代码来源:Client.php

示例7: 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

示例8: build

 /**
  * @param ConfigurationInterface $configuration
  * @param PayURequestInterface   $request
  *
  * @return Request
  */
 public function build(ConfigurationInterface $configuration, PayURequestInterface $request)
 {
     $curlRequest = new Request();
     if (PayURequestInterface::METHOD_POST === $request->getMethod()) {
         $curlRequest->setContent($this->serializer->toJson($request->getDataObject()));
     }
     $curlRequest->setHost(sprintf('%s://%s/', $configuration->getProtocol(), $configuration->getDomain()));
     $curlRequest->setResource(sprintf('%s/%s/%s', $configuration->getPath(), $configuration->getVersion(), $request->getPath()));
     $curlRequest->setMethod($request->getMethod());
     $this->addHeaders($curlRequest, $configuration);
     return $curlRequest;
 }
开发者ID:krzysztof-gzocha,项目名称:payu,代码行数:18,代码来源:CurlRequestBuilder.php

示例9: isSpam

 /**
  * Tells if the data looks like spam
  *
  * @param array $data
  * @return boolean
  */
 public function isSpam(array $data)
 {
     $data['blog'] = $this->blogUrl;
     $request = new Message\Request('POST', '/1.1/comment-check', $this->getHost());
     $request->setContent(http_build_query($data));
     $request->addHeader('Content-Type: application/x-www-form-urlencoded');
     $request->addHeader(sprintf('Content-Length: %d', strlen($request->getContent())));
     $response = new Message\Response();
     $client = new Client\Curl();
     $client->send($request, $response);
     return 'true' == $response->getContent();
 }
开发者ID:sblmasta,项目名称:OrnicarAkismetBundle,代码行数:18,代码来源:AkismetBuzzAdapter.php

示例10: testToStringFormatsTheRequest

 public function testToStringFormatsTheRequest()
 {
     $request = new Request('POST', '/resource/123', 'http://example.com');
     $request->setProtocolVersion(1.1);
     $request->addHeader('Content-Type: application/x-www-form-urlencoded');
     $request->setContent('foo=bar&bar=baz');
     $expected = "POST /resource/123 HTTP/1.1\r\n";
     $expected .= "Host: http://example.com\r\n";
     $expected .= "Content-Type: application/x-www-form-urlencoded\r\n";
     $expected .= "\r\n";
     $expected .= "foo=bar&bar=baz\r\n";
     $this->assertEquals($expected, (string) $request);
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:13,代码来源:RequestTest.php

示例11: testConvertsARequestToAContextArray

 public function testConvertsARequestToAContextArray()
 {
     $request = new Message\Request('POST', '/resource/123', 'http://example.com');
     $request->addHeader('Content-Type: application/x-www-form-urlencoded');
     $request->addHeader('Content-Length: 15');
     $request->setContent('foo=bar&bar=baz');
     $client = new StreamClient();
     $client->setMaxRedirects(5);
     $client->setIgnoreErrors(false);
     $client->setTimeout(10);
     $expected = array('http' => array('method' => 'POST', 'header' => "Content-Type: application/x-www-form-urlencoded\r\nContent-Length: 15", 'content' => 'foo=bar&bar=baz', 'protocol_version' => 1.0, 'ignore_errors' => false, 'max_redirects' => 5, 'timeout' => 10));
     $this->assertEquals($expected, $client->getStreamContextArray($request));
 }
开发者ID:kingsj,项目名称:core,代码行数:13,代码来源:AbstractStreamTest.php

示例12: sendRequest

 public function sendRequest()
 {
     // new Request
     $request = new Request($this->requestType, $this->resource, $this->host);
     // add headers
     $request->addHeaders($this->headers);
     // add body
     $request->setContent($this->body);
     // prepare client
     $response = new Response();
     $curl = new Curl();
     $curl->send($request, $response);
     $this->request = $request;
     $this->response = $response;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:15,代码来源:BuzzClient.php

示例13: createTokenResponse

 /**
  * {@inheritDoc}
  */
 public function createTokenResponse($clientId, $secret, $code, $redirectUrl = "")
 {
     $url = 'https://www.google.com/accounts/o8/oauth2/token';
     $request = new Request(Request::METHOD_POST, $url);
     $request->setContent(http_build_query(array('code' => $code, 'client_id' => $clientId, 'client_secret' => $secret, 'grant_type' => 'authorization_code', 'redirect_uri' => urldecode($redirectUrl))));
     $response = new Response();
     $this->client->send($request, $response);
     $data = json_decode($response->getContent());
     if (isset($data->error)) {
         return;
     }
     $expiresAt = time() + $data->expires_in;
     $people = 'https://www.googleapis.com/plus/v1/people/me' . '?key=' . $clientId . '&access_token=' . $data->access_token;
     $me = json_decode($this->request($people));
     return new GoogleToken($me, $data->access_token, $expiresAt);
 }
开发者ID:nucleartux,项目名称:OAuthBundle,代码行数:19,代码来源:GoogleProvider.php

示例14: request

 /**
  * Helper to send requests to Metrics API.
  *
  * @param string $path Path after metrics api version.
  * @param string $method HTTP Mthod, 'GET' or 'POST'.
  * @param array<string,array> $data Metrics data.
  *
  * @return stdClass
  */
 protected function request($path, $method, array $data = array())
 {
     $request = new Request();
     $response = new Response();
     $transport = $this->getTransport();
     $request->setMethod($method);
     $request->setResource($this->buildPath($path));
     $request->setHost(self::URI);
     $request->addHeader('Authorization: Basic ' . base64_encode($this->getAuthCredentials()));
     $request->addHeader('User-Agent: ' . $this->getUserAgent());
     if (count($data)) {
         $request->addHeader('Content-Type: application/json');
         $request->setContent(json_encode($data));
     }
     $transport->send($request, $response);
     return json_decode($response->getContent());
 }
开发者ID:nesQuick,项目名称:PHP-Metrics-Client,代码行数:26,代码来源:Client.php

示例15: bindCollection

 /**
  * @param  Buzz\Message\Request                           $request
  * @param  Doctrine\Common\Collections\Collection         $collection
  * @throws AntiMattr\Sears\Exception\IntegrationException
  */
 public function bindCollection(Request $request, Collection $collection)
 {
     $element = $this->xmlBuilder->setRoot('shipment-feed')->setNamespace('http://seller.marketplace.sears.com/oms/v5')->setSchemaLocation('http://seller.marketplace.sears.com/oms/v5 asn.xsd ')->create();
     // Hold all IntegrationExceptions until the end
     $exceptions = array();
     foreach ($collection as $shipment) {
         try {
             $this->xmlBuilder->addChild($element, 'shipment', $shipment->toArray());
         } catch (IntegrationException $e) {
             $orderId = $shipment->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,代码行数:25,代码来源:ShipmentRequestHandler.php


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