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


PHP Client::createRequest方法代码示例

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


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

示例1: postJSON

 private function postJSON($url, $headers, $payload)
 {
     $client = new Client();
     $request = $client->createRequest('POST', $url, ["Content-Type" => "application/json;charset=UTF-8", "Accept" => "application/json"] + $headers, $payload);
     $response = $request->send();
     $json = $response->getBody(true);
     return json_decode($json);
 }
开发者ID:exaprint,项目名称:php-rest-eventbus,代码行数:8,代码来源:RestApi.php

示例2: createRequest

 /**
  * {@inheritdoc}
  * Also includes the `api_id`, `user`, and `password` in the request if 
  * `session_id` has not been provided in the request.
  */
 public function createRequest($method = RequestInterface::GET, $uri = null, $headers = null, $body = null, array $options = array())
 {
     $request = parent::createRequest($method, $uri, $headers, $body, $options);
     if (!$request->getPostField("session_id")) {
         $config = $this->getConfig();
         $request->addPostFields($config->getAll(array('api_id', 'user', 'password')));
     }
     return $request;
 }
开发者ID:bluedogtraining,项目名称:guzzle-clickatell,代码行数:14,代码来源:ClickatellClient.php

示例3: createRequest

 /**
  * {@inheritDoc}
  */
 public function createRequest($method = RequestInterface::GET, $uri = null, $headers = null, $body = null, array $options = array())
 {
     $request = parent::createRequest($method, $uri, $headers, $body, $options);
     $config = $this->getConfig();
     // Add curl authentication to the request when username and password is set.
     if ($config->hasKey('username') && $config->hasKey('password')) {
         $authPlugin = new CurlAuthPlugin($config->get('username'), $config->get('password'));
         $this->addSubscriber($authPlugin);
     } elseif ($config->hasKey('client_id') && $config->hasKey('client_secret')) {
         $request->getQuery()->set('client_id', $config->get('client_id'))->set('client_secret', $config->get('client_secret'));
     }
     return $request;
 }
开发者ID:robinvdvleuten,项目名称:guzzle-clients,代码行数:16,代码来源:GithubClient.php

示例4: getGosling

 /**
  * Function doing an sql injection on GET with Guzzle
  * @param SqlTarget $target
  */
 public function getGosling(TargetInterface $target)
 {
     //defining $url and $params from $target
     //setting success to false by default
     $url = $target->getUrl();
     $repo = $this->_em->getRepository('AppBundle:SqlError');
     $sql_error = $repo->getSqlError();
     $params = $this->changeParamsToHackParams($target, $sql_error);
     $req = $this->_guzzle->createRequest('GET', $url, $params);
     $result = $this->goslingResponse($req, $url);
     $used_sql_error = $sql_error->getValue();
     $success = $result["Success"];
     $this->report($success, "for url " . $url . "and slq injection : " . $used_sql_error);
 }
开发者ID:haterecoil,项目名称:zerowing,代码行数:18,代码来源:SqlPentester.php

示例5: request

 /**
  * Dispatch API request
  *
  * @param string $method    HTTP method
  * @param string $path      Target path relative to base_url option value
  * @param object $paramData Request data
  *
  * @return mixed Response object
  */
 public function request($method, $path, $paramData)
 {
     $req = $this->client->createRequest($method, $path, array());
     $query = $req->getQuery();
     foreach ($paramData->queryParams() as $k => $v) {
         if ($v === null) {
             continue;
         }
         $query->add($k, is_bool($v) ? $v ? 'true' : 'false' : $v);
     }
     if ($method !== 'get' && $method !== 'delete') {
         $body = $paramData->requestBody();
         $json = empty($body) ? '{}' : json_encode($body);
         $req->setBody($json, 'application/json');
     }
     try {
         $res = $req->send();
         return $res->json();
     } catch (\Guzzle\Common\Exception\RuntimeException $e) {
         throw ApiConnectionException::inRequest($e);
     }
 }
开发者ID:kojiyamauchi,项目名称:WebPayAndPayPalAPISampleInWordPress,代码行数:31,代码来源:WebPay.php

示例6: request

 /**
  * Dispatch API request
  *
  * @param string $operation Target action
  * @param object $paramData Request data
  *
  */
 public function request($method, $path, $paramData)
 {
     if ($method == 'get' && count($paramData) > 0) {
         $path = $path . '?';
         foreach ($paramData as $k => $v) {
             $path .= $k . '=' . $v;
         }
         $paramData = array();
     }
     $this->setSignature($path, $paramData);
     $req = $this->client->createRequest($method, $path, array());
     if ($method == 'post' || $method == 'delete') {
         foreach ($paramData as $k => $v) {
             $req->setPostField($k, $v);
         }
     }
     try {
         $res = $req->send();
         return $res->json();
     } catch (\Guzzle\Common\Exception\RuntimeException $e) {
         echo $e->getResponse()->getBody();
     }
 }
开发者ID:augur0781,项目名称:coincheck-php,代码行数:30,代码来源:Coincheck.php

示例7: createRequest

 /**
  * Ensures that the duplicate query string aggregator is used so that
  * query string values are sent over the wire as foo=bar&foo=baz.
  * {@inheritdoc}
  */
 public function createRequest($method = 'GET', $uri = null, $headers = null, $body = null, array $options = array())
 {
     $request = parent::createRequest($method, $uri, $headers, $body, $options);
     $request->getQuery()->setAggregator($this->aggregator);
     return $request;
 }
开发者ID:risyasin,项目名称:webpagetest,代码行数:11,代码来源:AbstractClient.php

示例8: createRequest

 /**
  * Create and return a new RequestInterface configured for the client.
  *
  * Used internally by the library. Do not use directly.
  *
  * @param string                                    $method  HTTP method. Default to GET.
  * @param string|array                              $uri     Resource URI
  * @param array|Collection                          $headers HTTP headers
  * @param string|resource|array|EntityBodyInterface $body    Entity body of request (POST/PUT) or response (GET)
  * @param array                                     $options Array of options to apply to the request
  *
  * @return RequestInterface
  */
 public function createRequest($method = RequestInterface::GET, $uri = null, $headers = null, $body = null, array $options = array())
 {
     if (is_array($body)) {
         $body['pio_appkey'] = $this->getConfig()->get("appkey");
     } else {
         $body = array('pio_appkey' => $this->getConfig()->get("appkey"));
     }
     // Remove Guzzle internals to prevent them from going to the API
     unset($body[AbstractCommand::HEADERS_OPTION]);
     unset($body[AbstractCommand::ON_COMPLETE]);
     unset($body[AbstractCommand::DISABLE_VALIDATION]);
     unset($body[AbstractCommand::RESPONSE_PROCESSING]);
     unset($body[AbstractCommand::RESPONSE_BODY]);
     unset($body[AbstractCommand::HIDDEN_PARAMS]);
     if ($method == RequestInterface::GET || $method == RequestInterface::DELETE) {
         $request = parent::createRequest($method, $uri, $headers, null, $options);
         $request->getQuery()->replace($body);
     } else {
         $request = parent::createRequest($method, $uri, $headers, $body, $options);
     }
     $request->setPath($request->getPath() . ".json");
     return $request;
 }
开发者ID:ChenOhayon,项目名称:sitepoint_codes,代码行数:36,代码来源:PredictionIOClient.php

示例9: createMpiRequest

 /**
  * Creates mpi request as innovate api need it.
  *
  * @param string $method
  * @param string $uri
  * @param array $headers
  * @param string|resource|array|EntityBodyInterface $body
  * @return \Guzzle\Http\Message\RequestInterface
  */
 public function createMpiRequest($method = 'GET', $uri = null, $headers = null, $body = null)
 {
     $request = parent::createRequest($method, $uri, $headers, $body);
     if (!$body) {
         $request->createMpiBody($this->getStoreId(), $this->getKey(), $this->getTransaction(), $this->getCard(), $this->getBillingInformation(), $this->getBrowser());
     }
     return $request;
 }
开发者ID:digideskio,项目名称:innovate,代码行数:17,代码来源:Client.php

示例10: getChunks

 /**
  * @param string $bodyString
  * @see https://developers.google.com/safe-browsing/developers_guide_v2#HTTPRequestForData
  * @return array
  */
 public function getChunks($bodyString = '')
 {
     $resource = 'downloads';
     $client = new Client($this->getServiceUrl($resource));
     $request = $client->createRequest('POST', null, null, $bodyString);
     $response = $this->sendRequest($request);
     return array('code' => $response->getStatusCode(), 'data' => $response->getBody(true));
 }
开发者ID:silverslice,项目名称:yandex-php-library,代码行数:13,代码来源:SafeBrowsingClient.php

示例11: checkPublishing

 /**
  * @param string $path
  * @return string|bool
  */
 public function checkPublishing($path = '')
 {
     $client = new Client($this->getServiceUrl());
     $body = '<propfind xmlns="DAV:"><prop><public_url xmlns="urn:yandex:disk:meta"/></prop></propfind>';
     $request = $client->createRequest('PROPFIND', $path, array('Content-Length' => strlen($body), 'Depth' => '0'), $body);
     $result = $this->sendRequest($request)->xml()->children('DAV:');
     $propArray = (array) $result->response->propstat->prop->children();
     return empty($propArray['public_url']) ? (bool) false : (string) $propArray['public_url'];
 }
开发者ID:silverslice,项目名称:yandex-php-library,代码行数:13,代码来源:DiskClient.php

示例12: createRequest

 /**
  *
  * @see \Guzzle\Http\Client::createRequest()
  */
 public function createRequest($method = RequestInterface::POST, $uri = null, $headers = null, $body = null, array $options = array())
 {
     $request = parent::createRequest($method, $uri, $headers, $body, $options);
     return $request;
 }
开发者ID:svilborg,项目名称:guzzle-encoding-com,代码行数:9,代码来源:EncodingClient.php

示例13: updateDelivery

 /**
  * Update changed delivery parameters
  *
  * @param int $orderId
  * @param Models\Delivery $delivery
  * @return Models\Order
  *
  * Example:
  * PUT /v2/campaigns/10003/order/12345/delivery.json HTTP/1.1
  *
  * @link http://api.yandex.ru/market/partner/doc/dg/reference/put-campaigns-id-orders-id-delivery.xml
  */
 public function updateDelivery($orderId, Models\Delivery $delivery)
 {
     $resource = 'campaigns/' . $this->campaignId . '/orders/' . $orderId . '/delivery.json';
     $data = json_encode($delivery->toArray());
     $client = new Client($this->getServiceUrl($resource));
     $request = $client->createRequest('PUT', null, null, $data);
     $request->setHeader('Content-type', 'application/json');
     $response = $this->sendRequest($request)->json();
     $updateOrderDeliveryResponse = new Models\UpdateOrderDeliveryResponse($response);
     return $updateOrderDeliveryResponse->getOrder();
 }
开发者ID:silverslice,项目名称:yandex-php-library,代码行数:23,代码来源:PartnerClient.php

示例14: createRequest

 /**
  * {@inheritdoc}
  */
 public function createRequest($method = RequestInterface::GET, $uri = null, $headers = null, $body = null)
 {
     $request = parent::createRequest($method, $uri, $headers, $body);
     $request->setHeader('Content-Type', 'text/xml');
     return $request;
 }
开发者ID:gridonic,项目名称:guzzle-smsbox,代码行数:9,代码来源:SmsBoxClient.php

示例15: createRequest

 /**
  * {@inheritdoc}
  *
  * Prepends the {+base_path} expressions to the URI
  */
 public function createRequest($method = 'GET', $uri = null, $headers = null, $body = null, array $options = array())
 {
     $uri = '{+base_path}/' . ltrim($uri, '/');
     return parent::createRequest($method, $uri, $headers, $body, $options);
 }
开发者ID:cpliakas,项目名称:magento-client-php,代码行数:10,代码来源:MagentoRestClient.php


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