当前位置: 首页>>代码示例>>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;未经允许,请勿转载。