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


PHP Browser::post方法代碼示例

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


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

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

示例2: send

 /**
  * Sends the message via the GCM server.
  *
  * @param mixed $data
  * @param array $registrationIds
  * @param array $options
  * @param string $payload_type
  *
  * @return bool
  */
 public function send($data, array $registrationIds = array(), array $options = array(), $payload_type = 'data')
 {
     $this->responses = array();
     if (!in_array($payload_type, ['data', 'notification'])) {
         $payload_type = 'data';
     }
     $data = array_merge($options, array($payload_type => $data));
     if (isset($options['to'])) {
         $this->responses[] = $this->browser->post($this->apiUrl, $this->getHeaders(), json_encode($data));
     } elseif (count($registrationIds) > 0) {
         // Chunk number of registration ID's according to the maximum allowed by GCM
         $chunks = array_chunk($registrationIds, $this->registrationIdMaxCount);
         // Perform the calls (in parallel)
         foreach ($chunks as $registrationIds) {
             $data['registration_ids'] = $registrationIds;
             $this->responses[] = $this->browser->post($this->apiUrl, $this->getHeaders(), json_encode($data));
         }
     }
     $this->client->flush();
     foreach ($this->responses as $response) {
         $message = json_decode($response->getContent());
         if ($message === null || $message->success == 0 || $message->failure > 0) {
             return false;
         }
     }
     return true;
 }
開發者ID:faheem00,項目名稱:Gcm,代碼行數:37,代碼來源:Client.php

示例3:

    function it_parses_properly(MessageInterface $messageInterface)
    {
        $messageInterface->getContent()->willReturn(<<<JSON
[{
\t"command": "settings",
\t"settings": {
\t\t"basePath": "\\/",
\t\t"pathPrefix": "ca\\/",
\t\t"ajaxPageState": {
\t\t\t"theme": "bicing",
\t\t\t"theme_token": "NngnJfQN6FaHhoz6tHcHih5kFdxcm0b7EeWdAgd492M"
\t\t}
\t},
\t"merge": true
}, {
\t"command": "insert",
\t"method": null,
\t"selector": null,
\t"data": "[{\\u0022StationID\\u0022:\\u00221\\u0022,\\u0022StationName\\u0022:\\u002201 - C\\\\/ GRAN VIA CORTS CATALANES 760\\u0022,\\u0022DisctrictCode\\u0022:\\u00222\\u0022,\\u0022AddressGmapsLongitude\\u0022:\\u00222.180042000000000000\\u0022,\\u0022AddressGmapsLatitude\\u0022:\\u002241.39795200000000000\\u0022,\\u0022StationAvailableBikes\\u0022:\\u002217\\u0022,\\u0022StationFreeSlot\\u0022:\\u00222\\u0022,\\u0022AddressZipCode\\u0022:\\u002208013\\u0022,\\u0022AddressStreet1\\u0022:\\u0022Gran Via Corts Catalanes\\u0022,\\u0022AddressNumber\\u0022:\\u0022760\\u0022,\\u0022NearbyStationList\\u0022:\\u002224,369,387,426\\u0022,\\u0022StationStatusCode\\u0022:\\u0022OPN\\u0022}]",
\t"settings": null
}, {
\t"command": "insert",
\t"method": "prepend",
\t"selector": null,
\t"data": "",
\t"settings": null
}]
JSON
);
        $this->browser->post(BicingApi::BICING_URL)->willReturn($messageInterface);
        $this->getSnapshot()->shouldHaveCount(1);
    }
開發者ID:alexcarol,項目名稱:bicing-stats,代碼行數:32,代碼來源:BicingApiSpec.php

示例4: send

 /**
  * @inheritdoc
  */
 public function send($apikey, $address, $amount, $ip, $referral = false)
 {
     $url = $this->buildUrl('faucet/send', $apikey);
     $data = http_build_query(array('address' => $address, 'amount' => $amount, 'referral' => $referral, 'ip' => $ip));
     $response = $this->browser->post($url, $this->headers, $data);
     return new Response\FaucetSendResponse($response);
 }
開發者ID:looptribe,項目名稱:paytoshi-library-php,代碼行數:10,代碼來源:PaytoshiApi.php

示例5: send

 /**
  * Sends the data to the given registration IDs via the GCM server
  *
  * @param  \RMS\PushNotificationsBundle\Message\MessageInterface              $message
  * @throws \RMS\PushNotificationsBundle\Exception\InvalidMessageTypeException
  * @return bool
  */
 public function send(MessageInterface $message)
 {
     if (!$message instanceof AndroidMessage) {
         throw new InvalidMessageTypeException(sprintf("Message type '%s' not supported by GCM", get_class($message)));
     }
     if (!$message->isGCM()) {
         throw new InvalidMessageTypeException("Non-GCM messages not supported by the Android GCM sender");
     }
     $headers = array("Authorization: key=" . $this->apiKey, "Content-Type: application/json");
     $data = array_merge($message->getGCMOptions(), array("data" => $message->getData()));
     // Chunk number of registration IDs according to the maximum allowed by GCM
     $chunks = array_chunk($message->getGCMIdentifiers(), $this->registrationIdMaxCount);
     // Perform the calls (in parallel)
     $this->responses = array();
     foreach ($chunks as $registrationIDs) {
         $data["registration_ids"] = $registrationIDs;
         $this->responses[] = $this->browser->post($this->apiURL, $headers, json_encode($data));
     }
     // If we're using multiple concurrent connections via MultiCurl
     // then we should flush all requests
     if ($this->browser->getClient() instanceof MultiCurl) {
         $this->browser->getClient()->flush();
     }
     // Determine success
     foreach ($this->responses as $response) {
         $message = json_decode($response->getContent());
         if ($message === null || $message->success == 0 || $message->failure > 0) {
             return false;
         }
     }
     return true;
 }
開發者ID:Yameveo,項目名稱:RMSPushNotificationsBundle,代碼行數:39,代碼來源:AndroidGCMNotification.php

示例6: sendQuery

 /**
  * @return Buzz\Message\Response
  */
 public function sendQuery(Query $query, $url = self::URL)
 {
     $headers = array();
     $headers[] = 'User-Agent: SBBMobile/4.8 CFNetwork/609.1.4 Darwin/13.0.0';
     $headers[] = 'Accept: application/xml';
     $headers[] = 'Content-Type: application/xml';
     return $this->browser->post($url, $headers, $query->toXml());
 }
開發者ID:BJDev95,項目名稱:Transport,代碼行數:11,代碼來源:API.php

示例7: post

 /**
  * {@inheritdoc}
  */
 public function post($url, array $headers = array(), $content = '')
 {
     $response = $this->browser->post($url, $headers, $content);
     if (!$response->isSuccessful()) {
         throw $this->handleResponse($response);
     }
     return $response->getContent();
 }
開發者ID:fideloper,項目名稱:DigitalOceanV2,代碼行數:11,代碼來源:BuzzAdapter.php

示例8: isMarkupValid

 public function isMarkupValid($content)
 {
     $response = $this->browser->post('https://validator.w3.org/nu/?out=json', ['Content-Type' => 'text/html', 'User-Agent' => 'w3c api'], $content);
     $data = json_decode($response->getContent());
     $errors = array_filter($data->messages, function ($message) {
         return $message->type === 'error';
     });
     return count($errors) == 0;
 }
開發者ID:twentyua,項目名稱:html-validator-bundle,代碼行數:9,代碼來源:W3cValidator.php

示例9: send

 /**
  * @param string $endpoint
  * @param string $content
  * @param array $headers
  * @return Response
  */
 public function send($endpoint, $content, array $headers = array())
 {
     // Make headers buzz friendly
     array_walk($headers, function (&$value, $key) {
         $value = sprintf('%s: %s', $key, $value);
     });
     $response = $this->browser->post($endpoint, array_values($headers), $content);
     return new Response($response->getStatusCode(), $response->getContent());
 }
開發者ID:SerdarSanri,項目名稱:laravel-stampie,代碼行數:15,代碼來源:Buzz.php

示例10: call

 public function call(array $args)
 {
     $args['userkey'] = $this->apiKey;
     $response = $this->browser->post($this->apiUrl, [], $args);
     $data = json_decode($response->getContent(), true);
     if (isset($data['error_code'])) {
         throw new ApiCallException($data['error_desc'], $data['error_code']);
     }
     return $data;
 }
開發者ID:b17,項目名稱:plagiarism-checker,代碼行數:10,代碼來源:TextRuApi.php

示例11: post

 /**
  * Common post request for all API calls
  *
  * @param string $resource The path to the resource wanted. For example v2/room
  * @param array $content Parameters be posted for example:
  *                              array(
  *                                'name'                => 'Example name',
  *                                'privacy'             => 'private',
  *                                'is_archived'         => 'false',
  *                                'is_guest_accessible' => 'false',
  *                                'topic'               => 'New topic',
  *                              )
  *
  * @return array Decoded array containing response
  * @throws Exception\RequestException
  */
 public function post($resource, $content)
 {
     $url = $this->baseUrl . $resource;
     $headers = array('Content-Type' => 'application/json', 'Authorization' => $this->auth->getCredential());
     $response = $this->browser->post($url, $headers, json_encode($content));
     if ($this->browser->getLastResponse()->getStatusCode() > 299) {
         throw new RequestException(json_decode($this->browser->getLastResponse()->getContent(), true));
     }
     return json_decode($response->getContent(), true);
 }
開發者ID:kireol,項目名稱:stashCalendar,代碼行數:26,代碼來源:Client.php

示例12: flush

 /**
  * {@inheritDoc}
  */
 public function flush()
 {
     if (!$this->data['gauges'] && !$this->data['counters']) {
         return;
     }
     try {
         $this->browser->post('https://metrics-api.librato.com/v1/metrics', array('Authorization: Basic ' . base64_encode($this->username . ':' . $this->password), 'Content-Type: application/json'), json_encode($this->data));
         $this->data = array('gauges' => array(), 'counters' => array());
     } catch (\Exception $e) {
     }
 }
開發者ID:abreksa4,項目名稱:metrics,代碼行數:14,代碼來源:Librato.php

示例13: post

 /**
  * {@inheritdoc}
  */
 public function post($url, $content = '')
 {
     $headers = [];
     if (is_array($content)) {
         $content = json_encode($content);
         $headers[] = 'Content-Type: application/json';
     }
     $response = $this->browser->post($url, $headers, $content);
     $this->handleResponse($response);
     return $response->getContent();
 }
開發者ID:robertol,項目名稱:DigitalOceanV2,代碼行數:14,代碼來源:BuzzAdapter.php

示例14: search

 /**
  * {@inheritDoc}
  */
 public function search($query, $page = null)
 {
     try {
         $response = $this->browser->post($this->getUrl(), array(), $this->getQuery($query));
     } catch (\Exception $e) {
         throw new ConnectionException(sprintf('Could not connect to "%s"', $this->getUrl()), 0, $e);
     }
     if ($response->getStatusCode() != 200) {
         throw new UnexpectedResponseException(sprintf('Unexpected response: %s (%d)', $response->getReasonPhrase(), $response->getStatusCode()));
     }
     return $this->transformResponse($response->getContent());
 }
開發者ID:TomKita,項目名稱:Axon,代碼行數:15,代碼來源:EztvProvider.php

示例15: send

 /** {@inheritdoc} */
 public function send($uri, $payload)
 {
     try {
         /** @var $response Response */
         $response = $this->browser->post($uri, $this->getHeaders(true), $payload);
     } catch (RuntimeException $e) {
         throw TcpException::transportError($e);
     }
     if ($response->getStatusCode() !== 200) {
         throw HttpException::httpError($response->getReasonPhrase(), $response->getStatusCode());
     }
     return $response->getContent();
 }
開發者ID:Banjerr,項目名稱:infusionPress_Forms,代碼行數:14,代碼來源:BuzzBrowserBridge.php


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