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


PHP Client::options方法代碼示例

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


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

示例1: getStatusCodeForUrl

 /**
  * Get HTTP status code for URL
  * @param string $url The remote URL
  * @return int The HTTP status code
  */
 protected function getStatusCodeForUrl($url)
 {
     $httpResponse = $this->httpClient->options($url);
     return $httpResponse->getStatusCode();
 }
開發者ID:skylei,項目名稱:modern-php,代碼行數:10,代碼來源:Scanner.php

示例2: options

 /**
  * Sends a options request
  * @param string $uri
  * @param array $options Array such as
  *              'body' => [
  *                  'field' => 'abc',
  *                  'other_field' => '123',
  *                  'file_name' => fopen('/path/to/file', 'r'),
  *              ],
  *              'headers' => [
  *                  'foo' => 'bar',
  *              ],
  *              'cookies' => ['
  *                  'foo' => 'bar',
  *              ],
  *              'allow_redirects' => [
  *                   'max'       => 10,  // allow at most 10 redirects.
  *                   'strict'    => true,     // use "strict" RFC compliant redirects.
  *                   'referer'   => true,     // add a Referer header
  *                   'protocols' => ['https'] // only allow https URLs
  *              ],
  *              'save_to' => '/path/to/file', // save to a file or a stream
  *              'verify' => true, // bool or string to CA file
  *              'debug' => true,
  *              'timeout' => 5,
  * @return Response
  * @throws \Exception If the request could not get completed
  */
 public function options($uri, array $options = [])
 {
     $response = $this->client->options($uri, $options);
     return new Response($response);
 }
開發者ID:unrealbato,項目名稱:core,代碼行數:33,代碼來源:client.php

示例3: Client

<?php

/**
 * Created by PhpStorm.
 * User: raynald
 * Date: 4/16/15
 * Time: 10:00 AM
 */
// URL scanner app
// 1. Use Composer autoloader
require 'vendor/autoload.php';
use League\Csv\Reader;
use GuzzleHttp\Client;
// 2. Instantiate Guzzle HTTP client
$client = new Client();
// 3. Open and iterate CSV
// $csv = new \League\Csv\Reader($argv[1]);
$csv = Reader::createFromPath($argv[1]);
foreach ($csv as $url) {
    try {
        // 4. Send HTTP OPTIONS request
        $httpResponse = $client->options($url[0]);
        // 5. Inspect HTTP response status code
        if ($httpResponse->getStatusCode() >= 400) {
            throw new \Exception();
        }
    } catch (\Exception $e) {
        // 6. Print bad URL to standard out
        echo $url[0] . PHP_EOL;
    }
}
開發者ID:raynaldmo,項目名稱:php-education,代碼行數:31,代碼來源:scan.php


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