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


PHP Client::options方法代码示例

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


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

示例1: existsResource

 public function existsResource($uri)
 {
     $client = new Client();
     $request = $client->options($this->getServiceUrl($uri), array("User-Agent" => "Marmotta Client Library (PHP)"));
     // set authentication if given in configuration
     if (!_isset($this->config->getUsername())) {
         $request->setAuth($this->config->getUsername(), $this->config->getPassword());
     }
     $response = $request->send();
     if ($response->hasHeader("Access-Control-Allow-Methods")) {
         if ($response->getHeader("Access-Control-Allow-Methods") == "POST") {
             return False;
         } else {
             if (strpos($response->getHeader("Access-Control-Allow-Methods"), "GET")) {
                 return True;
             } else {
                 return False;
             }
         }
     } else {
         return False;
     }
 }
开发者ID:ximdex,项目名称:marmotta-client,代码行数:23,代码来源:ResourceClient.php

示例2: testUriArrayAllowsCustomTemplateVariables

 public function testUriArrayAllowsCustomTemplateVariables()
 {
     $client = new Client();
     $vars = array('var' => 'hi');
     $this->assertEquals('/hi', (string) $client->createRequest('GET', array('/{var}', $vars))->getUrl());
     $this->assertEquals('/hi', (string) $client->get(array('/{var}', $vars))->getUrl());
     $this->assertEquals('/hi', (string) $client->put(array('/{var}', $vars))->getUrl());
     $this->assertEquals('/hi', (string) $client->post(array('/{var}', $vars))->getUrl());
     $this->assertEquals('/hi', (string) $client->head(array('/{var}', $vars))->getUrl());
     $this->assertEquals('/hi', (string) $client->options(array('/{var}', $vars))->getUrl());
 }
开发者ID:carlesgutierrez,项目名称:libreobjet.org,代码行数:11,代码来源:ClientTest.php

示例3: Client

require '../vendor/autoload.php';
use Guzzle\Http\Client;
use Faker\Factory;
$faker = Factory::create();
$client = new Client('http://localhost/comphppuebla/guzzle/api');
$acceptJson = ['Accept' => 'application/json'];
$acceptXml = ['Accept' => 'application/xml'];
$request = $client->get('contacts/1', $acceptXml);
$response = $request->send();
echo "\nGET /contacts/1\n";
echo $response->getBody();
$contact = ['name' => $faker->firstName, 'last_name' => $faker->lastName];
$request = $client->post('contacts', $acceptJson, http_build_query($contact));
$response = $request->send();
echo "\n\nPOST /contacts\n";
echo $response->getBody();
$newName = $faker->firstName;
$contact = ['name' => $newName];
$request = $client->put('contacts/2', $acceptXml, http_build_query($contact));
$response = $request->send();
echo "\n\nPUT /contacts/2 (New name is {$newName})\n";
echo $response->getBody();
echo "Last modified time: {$response->getLastModified()}";
$request = $client->delete('contacts/3');
$response = $request->send();
echo "\n\nDELETE /contacts/3\n";
echo "Status code: {$response->getStatusCode()}";
$request = $client->options('contacts/4');
$response = $request->send();
echo "\n\nOPTIONS /contacts/4\n";
echo "Valid methods are: {$response->getAllow()}";
开发者ID:comphppuebla,项目名称:guzzlesfd,代码行数:31,代码来源:http.php


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