當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Browser::submit方法代碼示例

本文整理匯總了PHP中Buzz\Browser::submit方法的典型用法代碼示例。如果您正苦於以下問題:PHP Browser::submit方法的具體用法?PHP Browser::submit怎麽用?PHP Browser::submit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Buzz\Browser的用法示例。


在下文中一共展示了Browser::submit方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: submit

 /**
  * Submit a request to the API.
  * 
  * @param Requestable $request
  * @return object
  */
 public function submit(RequestableInterface $request)
 {
     $this->applyDefaultOptions($request);
     $url = $this->options['host'] . $request->getPath();
     $data = Packer::pack($request);
     return new Response($this->browser->submit($url, $data));
 }
開發者ID:noetix,項目名稱:traction-php,代碼行數:13,代碼來源:Handler.php

示例2: send

 /**
  * @param string $endpoint
  * @param string $content
  * @param array $headers
  * @param array $files
  * @return Response
  */
 public function send($endpoint, $content, array $headers = array(), array $files = array())
 {
     // Make headers buzz friendly
     array_walk($headers, function (&$value, $key) {
         $value = sprintf('%s: %s', $key, $value);
     });
     if ($files) {
         // HTTP query content
         parse_str($content, $fields);
         // Add files to request
         foreach ($files as $key => $items) {
             $fields[$key] = array();
             foreach ($items as $name => $item) {
                 $item = new FormUpload($item);
                 if (!is_numeric($name)) {
                     $item->setName($name);
                 }
                 $fields[$key] = $item;
             }
         }
         $response = $this->browser->submit($endpoint, $fields, RequestInterface::METHOD_POST, array_values($headers));
     } else {
         // JSON content
         $response = $this->browser->post($endpoint, array_values($headers), $content);
     }
     return new Response($response->getStatusCode(), $response->getContent());
 }
開發者ID:andorpandor,項目名稱:git-deploy.eu2.frbit.com-yr-prototype,代碼行數:34,代碼來源:Buzz.php

示例3: call

 /**
  * {@inheritDoc}
  */
 public function call(RequestInterface $request)
 {
     /**
      * @var Response $response
      */
     $response = $this->browser->submit($this->getEndpoint(), $request->getParameters());
     if ($response->isSuccessful()) {
         return $response->getContent();
     } else {
         return false;
     }
 }
開發者ID:ybensacq,項目名稱:LexikPayboxBundle,代碼行數:15,代碼來源:BuzzTransport.php

示例4: validate

 /**
  * Checks if the passed value is valid.
  *
  * @param mixed $value The value that should be validated
  * @param Constraint $constraint The constraint for the validation
  *
  * @api
  */
 public function validate($value, Constraint $constraint)
 {
     $reCaptchaResponse = $this->request->request->get('g-recaptcha-response');
     if (empty($reCaptchaResponse)) {
         $this->context->addViolation($constraint->message);
         return;
     }
     $response = $this->buzz->submit('https://www.google.com/recaptcha/api/siteverify', ['secret' => $this->secret, 'response' => $reCaptchaResponse, 'remoteip' => $this->request->getClientIp()]);
     $reCaptchaValidationResponse = json_decode($response->getContent());
     if (true !== $reCaptchaValidationResponse->success) {
         $this->context->addViolation($constraint->message);
     }
 }
開發者ID:alienpham,項目名稱:portfolio,代碼行數:21,代碼來源:ValidCaptchaValidator.php

示例5: send

 /**
  * Send request and generate response.
  *
  * @param Bool secure
  *
  * @throws UniversalAnalytics\Exception\InvalidRequestException
  *
  * @return Response
  */
 public function send($secure = true)
 {
     $buzzBrowser = new Browser();
     $buzzBrowser->setClient(new Curl());
     $base = $secure ? $this->base_ssl : $this->base;
     $buzzResponse = $buzzBrowser->submit($base, $this->attributes, RequestInterface::METHOD_POST, array());
     return new Response($buzzResponse);
 }
開發者ID:kapai69,項目名稱:fl-ru-damp,代碼行數:17,代碼來源:Request.php

示例6: httpRequest

 /**
  * {@inheritdoc}
  */
 public function httpRequest($uri, array $body = [], array $headers = [], $method = 'POST')
 {
     try {
         $response = $this->httpTransporter->submit($uri, $body, $method, $headers);
     } catch (RequestException $e) {
         throw new TokenResponseException($e->getMessage() ? $e->getMessage() : 'Failed to request resource.');
     }
     return $response->getContent();
 }
開發者ID:BirknerAlex,項目名稱:php-oauth,代碼行數:12,代碼來源:AbstractService.php

示例7: iSubmitDataTo

 /**
  * @When /^I submit "([^"]*)" data to "([^"]*)"$/
  * @param  string     $pageUrl
  * @return void
  * @throws \Exception
  */
 public function iSubmitDataTo($dataKey, $pageUrl)
 {
     $this->responseData = $this->responseDecodeException = null;
     $this->responseIsJson = false;
     if ($this->access_token) {
         $this->headers['Authorization'] = 'Bearer ' . $this->access_token;
     }
     $this->client->submit($this->processPageUrl($pageUrl), array($dataKey => $this->collectedData[$dataKey]), strtolower($this->requestMethod), $this->headers);
     $this->response = $this->client->getLastResponse();
 }
開發者ID:kartoffelkage,項目名稱:Newscoop,代碼行數:16,代碼來源:RestContext.php

示例8: getRawResponse

 /**
  * Returns raw response for request.
  *
  * @return string
  * @throws \Paybox\Exception\Http
  */
 protected function getRawResponse()
 {
     /** @var \Buzz\Message\Response $result */
     $uri = sprintf('%s://%s%s', $this->scheme, $this->host, $this->getRequestUrl());
     $result = $this->browser->submit($uri, (new Sign($this->secret))->sign($uri, $this->toArray()));
     if ($result->isClientError() || $result->isServerError()) {
         if ($result->getStatusCode() >= 400) {
             throw new Http(sprintf('Paybox responded with code %d: %s', $result->getStatusCode(), $result->getContent()), $result->getStatusCode());
         }
     }
     return $result->getContent();
 }
開發者ID:iborodikhin,項目名稱:paybox,代碼行數:18,代碼來源:Base.php

示例9: send

 /**
  * Send request and generate response
  *
  * @param Bool secure
  * @throws UniversalAnalytics\Exception\InvalidRequestException
  * @return Response
  */
 public function send($secure = true)
 {
     $headers = array();
     if (is_null($this->user_agent_string) === false) {
         $headers['User-Agent'] = $this->user_agent_string;
     }
     $buzzBrowser = new Browser();
     $buzzBrowser->setClient(new Curl());
     $base = $secure ? $this->base_ssl : $this->base;
     $buzzResponse = $buzzBrowser->submit($base, $this->attributes, RequestInterface::METHOD_POST, $headers);
     return new Response($buzzResponse);
 }
開發者ID:fideloper,項目名稱:universalanalytics,代碼行數:19,代碼來源:Request.php

示例10: request

 /**
  * Send an http request
  *
  * @param string $method     The HTTP method
  * @param string $url        The url to send the request to
  * @param array  $parameters The parameters for the request (assoc array)
  * @param array  $headers    The headers for the request (assoc array)
  *
  * return mixed
  */
 public function request($method, $url, array $parameters = null, array $headers = null)
 {
     // add query parameters to the url if needed
     if (isset($parameters['query']) && is_array($parameters['query'])) {
         $query = parse_url($url, PHP_URL_QUERY);
         $url .= ($query === null ? '?' : '&') . http_build_query($parameters['query']);
     }
     // make sure files are added as a form upload
     if ($method === 'POST') {
         foreach ($parameters as $key => $value) {
             if (is_string($value) && substr($value, 0, 1) == '@') {
                 $value = ltrim($value, '@');
                 $parameters[$key] = new FormUpload($value);
             }
         }
     }
     // buzz requires us to send an array of parameters instead of null
     if (empty($parameters)) {
         $parameters = array();
     }
     $response = $this->browser->submit($url, $parameters, $method, $headers);
     return json_decode($response->getContent(), true);
 }
開發者ID:WouterSioen,項目名稱:showpad-api-buzz,代碼行數:33,代碼來源:BuzzAdapter.php

示例11: __call

 /**
  * Perform an HTTP call
  *
  * $arguments is made of two arguments:
  * - first: route (Example: "{token}/ticket/list/{root}")
  * - second: parameters (Example: array("{root}" => "12", "key1" => "value2"), optionnal)
  *   => {token}/ticket/list/12?key1=value2
  *
  * @param string $method
  * @param array $arguments
  * @return array
  */
 public function __call($method, $arguments)
 {
     // Check for arguments
     if (empty($arguments)) {
         throw new Exception("No arguments have been passed to ApiMapper::{$method}()");
     }
     // Extracts arguments (Note $parameters and $fields are optionnal)
     $route = array_shift($arguments);
     $parameters = empty($arguments) ? array() : array_shift($arguments);
     $fields = empty($arguments) ? array() : array_shift($arguments);
     // Fill route placeholders, and append query fields
     $url = $this->buildUrl($route, $parameters);
     // Add post field parameter providers
     foreach ($this->postFieldsParameters as $fieldName => $field) {
         $field = $field->lookup($route);
         if ($field !== false) {
             $fields[$fieldName] = $field;
         }
     }
     // Load headers
     $headers = array();
     foreach ($this->headerProviders as $headerProvider) {
         $header = $headerProvider->lookup($route);
         if ($header !== false) {
             $headers[] = $header;
         }
     }
     // Perform the call
     if (static::isSafeMethod($method)) {
         $response = $this->browser->call($url, $method, $headers);
     } else {
         $response = $this->browser->submit($url, $fields, $method, $headers);
     }
     // Parse the content
     $content = array("method" => strtoupper($method), "route" => $route, "url" => $url, "response" => $response, "parameters" => $parameters, "json" => json_decode($response->getContent(), true));
     // Dispatch content to event listeners
     $this->dispatch($content);
     // Return the content
     return $content;
 }
開發者ID:rgsystemes,項目名稱:apimapper,代碼行數:52,代碼來源:ApiMapper.php

示例12: request

 protected function request($url, $data = array(), $method = 'POST', array $headers = array())
 {
     if ($data instanceof Form) {
         $data = $data->toArray();
     }
     $client = new Curl();
     $client->setTimeout(100);
     $client->setVerifyPeer(FALSE);
     $browser = new Browser($client);
     $response = $browser->submit($url, $data, $method, $headers);
     return $response->getContent();
 }
開發者ID:gyorgygilanyi,項目名稱:dpd-shipping-api,代碼行數:12,代碼來源:API.php

示例13: getAccessToken

 private function getAccessToken()
 {
     $response = $this->browser->submit(static::ACCESS_TOKEN_API_ENDPOINT, array('client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'scope' => 'http://api.microsofttranslator.com', 'grant_type' => 'client_credentials'));
     $data = json_decode($response->getContent());
     return $data->access_token;
 }
開發者ID:dhensen,項目名稱:translator,代碼行數:6,代碼來源:BingTranslator.php


注:本文中的Buzz\Browser::submit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。