當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。