本文整理汇总了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;
}
}
示例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());
}
示例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()}";