本文整理汇总了PHP中GuzzleHttp\Client::getBaseUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::getBaseUrl方法的具体用法?PHP Client::getBaseUrl怎么用?PHP Client::getBaseUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GuzzleHttp\Client
的用法示例。
在下文中一共展示了Client::getBaseUrl方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Send data to remote JSON-RPC service over HTTP.
*
* @throws \Josser\Exception\TransportFailureException
* @param mixed $data
* @return string
*/
public function send($data)
{
try {
$response = $this->guzzle->post(null, ['body' => $data, 'headers' => ['Content-Type' => 'application/json']]);
return $response->getBody()->getContents();
} catch (\Exception $e) {
$error = sprintf('JSON-RPC http connection failed. Remote service at "%s" is not responding.', $this->guzzle->getBaseUrl());
throw new TransportFailureException($error, null, $e);
}
}
示例2: __construct
/**
* SharePoint Site constructor
*
* @access public
* @param \GuzzleHttp\Client $http Guzzle HTTP client
* @param array $config SharePoint Site configuration
* @throws SPException
* @return SPSite
*/
public function __construct(Client $http, array $config)
{
$this->config = array_replace_recursive(['acs' => static::ACS], $config);
// set Guzzle HTTP client
$this->http = $http;
// set Site Hostname and Path
$components = parse_url($this->http->getBaseUrl());
if (!isset($components['scheme'], $components['host'], $components['path'])) {
throw new SPException('The SharePoint Site URL is invalid');
}
$this->hostname = $components['scheme'] . '://' . $components['host'];
$this->path = rtrim($components['path'], '/');
}
示例3: __construct
public function __construct($id, $token, Client $client = null)
{
if (!$client) {
$client = new Client(['base_url' => self::ENDPOINT]);
}
if (!$client->getBaseUrl()) {
throw new Exception\ClientException('API client is not configured with a base URL');
}
if (!ctype_xdigit($id) || !ctype_xdigit($token)) {
throw new Exception\ClientException('User credentials are invalid');
}
$client->setDefaultOption('headers', ['Auth' => "Bearer {$id} {$token}", 'User-Agent' => 'WIU PHP Client/1.0']);
$this->client = $client;
}
示例4: testCanSpecifyBaseUrlUriTemplate
public function testCanSpecifyBaseUrlUriTemplate()
{
$client = new Client(['base_url' => ['http://foo.com/{var}/', ['var' => 'baz']]]);
$this->assertEquals('http://foo.com/baz/', $client->getBaseUrl());
}
示例5: jsonSerialize
/**
* Implements \JsonSerializable::jsonSerialize.
*/
public function jsonSerialize()
{
return ['url' => $this->client->getBaseUrl(), 'username' => $this->username, 'password' => $this->password, 'authToken' => $this->authToken, 'accessToken' => $this->accessToken, 'refreshToken' => $this->refreshToken, 'settings' => $this->settings];
}
示例6: getBaseUri
public function getBaseUri()
{
return $this->client->getBaseUrl();
}
示例7: copyClientDefaults
/**
* @param Client $client
*/
protected function copyClientDefaults(Client $client)
{
$this->request->setUrl($client->getBaseUrl() . $this->request->getUrl());
$this->request->addHeaders($client->getDefaultOption('headers'));
}