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


PHP Client::getConfig方法代码示例

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


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

示例1: post

 public function post($full_url, array $multi_parts = [], array $headers = [])
 {
     $options = ['debug' => GUZZLE_DEBUG];
     // Grab the client's handler instance.
     $clientHandler = $this->client->getConfig('handler');
     // Create a middleware that echoes parts of the request.
     $tapMiddleware = Middleware::tap(function ($request) {
         echo $request->getHeader('Content-Type');
         // application/json
         echo $request->getBody();
         // {"foo":"bar"}
     });
     //$options['handler'] = $tapMiddleware($clientHandler);
     $multi_part_vars = array();
     foreach ($multi_parts as $name => $data) {
         if (is_array($data)) {
             $data['name'] = $name;
         } else {
             $data = ['name' => $name, 'contents' => $data];
         }
         $multi_part_vars[] = $data;
     }
     $options['multipart'] = $multi_part_vars;
     //$options['headers'] = ['Referer' =>  $full_url];
     if (!empty($headers)) {
         $options['headers'] = $headers;
     }
     $this->response = $this->client->post($full_url, $options);
     return $this;
 }
开发者ID:vantt,项目名称:vocabulary-crawler,代码行数:30,代码来源:GuzzleHttpRequest.php

示例2: copyClientDefaults

 /**
  * @param Client $client
  */
 protected function copyClientDefaults(Client $client)
 {
     $this->request->withUri(new Uri($client->getConfig('base_uri') . $this->request->getUri()));
     foreach ($client->getConfig('headers') as $header => $value) {
         $this->request->withAddedHeader($header, $value);
     }
 }
开发者ID:NeokamiCode,项目名称:box-php-sdk,代码行数:10,代码来源:AbstractCommand.php

示例3: render

 /**
  *
  * @param SquarespacePage $page
  * @return mixed
  */
 public function render(SquarespacePage $page)
 {
     $response = $this->client->get($this->extractResourceFromUri($this->base_url, $page->getUrl()), ['exceptions' => false, 'cookies' => $this->authenticationService->jar]);
     if ($response->getStatusCode() === Response::HTTP_UNAUTHORIZED) {
         $this->authenticationService->authenticate();
         $response = $this->client->get($this->extractResourceFromUri($this->base_url, $page->getUrl()), ['exceptions' => false, 'cookies' => $this->authenticationService->jar]);
     }
     return $this->buildAbsolutePaths($this->client->getConfig('base_uri'), $response->getBody());
 }
开发者ID:beloop,项目名称:components,代码行数:14,代码来源:PageRenderer.php

示例4: __construct

 /**
  * PageRenderer constructor.
  * @param LoggerInterface $logger
  * @param Client $client
  */
 public function __construct(LoggerInterface $logger, SessionInterface $session, Client $client)
 {
     $this->logger = $logger;
     $this->session = $session;
     $this->client = $client;
     $this->jar = $this->session->get(static::COOKIE_JAR, new CookieJar());
     $this->base_url = $client->getConfig('base_uri')->__toString();
     $this->host = $client->getConfig('base_uri')->getHost();
 }
开发者ID:beloop,项目名称:components,代码行数:14,代码来源:PageRenderer.php

示例5: send

 /**
  * Send data to remote JSON-RPC service over HTTP.
  *
  * @throws \Josser\Exception\TransportFailureException
  * @param mixed $data
  * @return string
  */
 public function send($data)
 {
     try {
         $response = $this->guzzle->request('POST', null, ['body' => $data, 'headers' => ['Content-Type' => 'application/json']]);
         return $response->getBody()->getContents();
     } catch (\Exception $e) {
         $error = sprintf('JSON-RPC http connection failed. Remote service at "%s" is not responding.', $this->guzzle->getConfig('base_uri'));
         throw new TransportFailureException($error, null, $e);
     }
 }
开发者ID:alanbem,项目名称:josser,代码行数:17,代码来源:Guzzle6Transport.php

示例6: registerPanel

 public function registerPanel(Panel $panel)
 {
     $handler = $this->client->getConfig('handler');
     if ($handler instanceof HandlerStack) {
         $handler->push(Middleware::tap(NULL, function (Request $request) use($panel) {
             $panel->addRequest(Json::decode($request->getBody()));
         }));
     }
     return $this;
 }
开发者ID:lookyman,项目名称:mandrill,代码行数:10,代码来源:GuzzleClient.php

示例7: reverse

 /**
  * Reverse action
  *
  * @param $latitude
  * @param $longitude
  *
  * @return \Psr\Http\Message\ResponseInterface
  */
 public function reverse($latitude, $longitude)
 {
     if (!$this->isLatitude($latitude)) {
         throw new \InvalidArgumentException('Wrong value for latitude.');
     }
     if (!$this->isLongitude($longitude)) {
         throw new \InvalidArgumentException('Wrong value for longitude.');
     }
     $response = $this->guzzleClient->get('reverse', ['query' => ['format' => $this->guzzleClient->getConfig('format'), 'lat' => $latitude, 'lon' => $longitude, 'addressdetails' => $this->guzzleClient->getConfig('addressdetails')]]);
     return $response;
 }
开发者ID:mauro-moreno,项目名称:openstreetmap-api-client,代码行数:19,代码来源:NominatimClient.php

示例8: send

 /**
  * Call Google API endpoint using the parameters and method supplied.
  *
  * @param  string $method
  * @param  string $api_func
  * @param  array  $query
  *
  * @return ResponseInterface
  */
 protected function send($method, $api_func, array $query)
 {
     // Google Books API supported methods
     $accepted_methods = ['GET', 'POST'];
     if (!in_array(strtoupper($method), $accepted_methods)) {
         throw new \InvalidArgumentException('HTTP method is not valid for Google Books search endpoints.');
     }
     $query['query'] += $this->client->getConfig('query');
     /** @var Response $response */
     $response = call_user_func([$this->client, $method], $api_func, $query);
     return $response;
 }
开发者ID:Nerdstorm,项目名称:Google-Books,代码行数:21,代码来源:AbstractSearchBase.php

示例9: __construct

 /**
  * ScoreRetriever constructor.
  * @param LoggerInterface $logger
  * @param Client $client
  */
 public function __construct(LoggerInterface $logger, Client $client, $apiKey)
 {
     $this->logger = $logger;
     $this->client = $client;
     $this->apiKey = $apiKey;
     $this->base_url = $client->getConfig('base_uri')->__toString();
 }
开发者ID:beloop,项目名称:components,代码行数:12,代码来源:ScoreRetriever.php

示例10: __construct

 /**
  * WOS Client constructor
  *
  * The constructor expects a guzzleClient with the base_url value set, and
  * any default options that should be used on all requests.
  *
  * For convenience, you probably want to set the 'x-ddn-policy' header by
  * default.  See the self::build() method above for an example of setting
  * this.
  *
  * @param Client $guzzleClient
  */
 public function __construct(Client $guzzleClient)
 {
     if (!isset($guzzleClient->getConfig()['base_uri'])) {
         throw new \RuntimeException("Cannot instantiate a WosClient without 'base_uri' set in Guzzle");
     }
     $this->guzzleClient = $guzzleClient;
 }
开发者ID:caseyamcl,项目名称:wosclient,代码行数:19,代码来源:WosClient.php

示例11: doRequest

 protected function doRequest($request)
 {
     /** @var $request BrowserKitRequest  **/
     $guzzleRequest = new Psr7Request($request->getMethod(), $request->getUri(), $this->extractHeaders($request), $request->getContent());
     $options = $this->requestOptions;
     $options['cookies'] = $this->extractCookies($guzzleRequest->getUri()->getHost());
     $multipartData = $this->extractMultipartFormData($request);
     if (!empty($multipartData)) {
         $options['multipart'] = $multipartData;
     }
     $formData = $this->extractFormData($request);
     if (empty($multipartData) and $formData) {
         $options['form_params'] = $formData;
     }
     try {
         $response = $this->client->send($guzzleRequest, $options);
     } catch (ConnectException $e) {
         $url = (string) $this->client->getConfig('base_uri');
         throw new ConnectionException("Couldn't connect to {$url}. Please check that web server is running");
     } catch (RequestException $e) {
         if (!$e->hasResponse()) {
             throw $e;
         }
         $response = $e->getResponse();
     }
     return $this->createResponse($response);
 }
开发者ID:RobertWang,项目名称:Codeception,代码行数:27,代码来源:Guzzle6.php

示例12: toApi

 public function toApi(Request $request)
 {
     $client = new \GuzzleHttp\Client();
     $input = $request::all();
     $command = 'request';
     $api_key = 'MjuhMtfAAfvJqzbnWFLA';
     // $api_key = 'mysendykey';
     $api_username = 'chris-stop';
     // $api_username = 'mysendyusername';
     $from_name = 'Chris Munialo';
     $from_lat = $input['lat'];
     $from_long = $input['lng'];
     $from_description = '';
     $to_name = 'TRM';
     $to_lat = $input['lat1'];
     $to_long = $input['lng1'];
     $to_description = '';
     $recepient_name = 'John';
     $recepient_phone = '0710000000';
     $recepient_email = 'John@doe.com';
     $pick_up_date = '2016-04-20 12:12:12';
     $status = false;
     $pay_method = 0;
     $amount = 10;
     $return = true;
     $note = 'Sample note';
     $note_status = true;
     $request_type = 'quote';
     $info = ['command' => $command, 'data' => ['api_key' => $api_key, 'api_username' => $api_username, 'from' => ['from_name' => $from_name, 'from_lat' => floatval($from_lat), 'from_long' => floatval($from_long), 'from_description' => $from_description], 'to' => ['to_name' => $to_name, 'to_lat' => floatval($to_lat), 'to_long' => floatval($to_long), 'to_description' => $to_description], 'recepient' => ['recepient_name' => $recepient_name, 'recepient_phone' => $recepient_phone, 'recepient_email' => $recepient_email], 'delivery_details' => ['pick_up_date' => $pick_up_date, 'collect_payment' => ['status' => $status, 'pay_method' => $pay_method, 'amount' => $amount], 'return' => $return, 'note' => $note, 'note_status' => $note_status, 'request_type' => $request_type]]];
     $clientHandler = $client->getConfig('handler');
     // Create a middleware that echoes parts of the request.
     $tapMiddleware = Middleware::tap(function ($request) {
         $request->getHeader('Content-Type');
         // application/json
         $request->getBody();
         // {"foo":"bar"}
     });
     $endpoint = 'https://developer.sendyit.com/v1/api/#request';
     // $info = json_encode($info);
     $client = new \GuzzleHttp\Client();
     $res = $client->request('POST', $endpoint, ['json' => $info, 'handler' => $tapMiddleware($clientHandler), 'headers' => ['Accept' => 'application/json']]);
     // $res->getStatusCode();
     // "200"
     // $res->getHeader('content-type');
     // 'application/json; charset=utf8'
     $pns = json_decode($res->getBody(), true);
     // var_dump($pns);
     // echo $pns;
     // echo $pns;
     // $pns= $res->getBody();
     // {"type":"User"...
     // Send an asynchronous request.
     // $request = new \GuzzleHttp\Psr7\Request('POST', $endpoint );
     // $promise = $client->sendAsync($request)->then(function ($response) {
     // $response->getBody();
     // });
     // $promise->wait();
     return view('orders.new', ['pns' => $pns]);
 }
开发者ID:krysmunialo,项目名称:sendy---request_delivery,代码行数:59,代码来源:OrdersController.php

示例13: getRequestOptions

 /**
  * Returns request options
  * 
  * @param Request $request
  * @return array
  */
 private function getRequestOptions(Request $request)
 {
     $options = ['http_errors' => false, 'synchronous' => true];
     if ($request->getQuery()) {
         $options['query'] = array_merge($this->guzzleClient->getConfig('query'), $request->getQuery());
     }
     if ($request->getParams()) {
         $options['json'] = $request->getParams();
     }
     return $options;
 }
开发者ID:rulecom,项目名称:api-wrapper,代码行数:17,代码来源:Client.php

示例14: getCookie

 /**
  * Get a cookie from a GuzzleClient.
  *
  * @param Client $client
  * @param string $name
  *
  * @return \GuzzleHttp\Cookie\SetCookie
  *
  * @throws SteamLoginException If the cookie doesn't exist in the client
  */
 public static function getCookie(Client $client, $name)
 {
     /** @var \GuzzleHttp\Cookie\CookieJar $cookies */
     $cookies = $client->getConfig('cookies');
     foreach ($cookies as $cookie) {
         /** @var \GuzzleHttp\Cookie\SetCookie $cookie */
         if ($cookie->getName() == $name) {
             return $cookie;
         }
     }
     throw new SteamLoginException('Cookie not set');
 }
开发者ID:drdelay,项目名称:steam-login,代码行数:22,代码来源:Utils.php

示例15: log

 protected function log($uri, $method, $params, Response $response = null, $duration = 0)
 {
     if (!$this->logger) {
         return;
     }
     foreach ($params as $k => &$v) {
         if ($k == 'password') {
             $v = '***';
         }
     }
     $data = ['request' => ['params' => $params, 'response' => $response ? ['status' => $response->getStatusCode(), 'body' => (string) $response->getBody()] : null], 'duration' => $duration, 'pid' => getmypid()];
     $this->logger->debug("{$method} {$this->guzzle->getConfig('base_uri')}{$uri}", array_merge($this->logData, $data));
 }
开发者ID:keboola,项目名称:gooddata-php-client,代码行数:13,代码来源:Client.php


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