本文整理汇总了PHP中Guzzle\Service\Client::setDefaultOption方法的典型用法代码示例。如果您正苦于以下问题:PHP Client::setDefaultOption方法的具体用法?PHP Client::setDefaultOption怎么用?PHP Client::setDefaultOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Guzzle\Service\Client
的用法示例。
在下文中一共展示了Client::setDefaultOption方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Initializes the BeHat context for every scenario
*
* @param array $parameters Context parameters defined in behat.yml (default.context.parameters...)
*/
public function __construct(array $parameters)
{
$this->client = new \Guzzle\Service\Client();
$this->client->setDefaultOption('exceptions', false);
// disable exceptions: we want to test error responses
self::$parameters = $parameters;
$this->restObj = new \stdClass();
}
示例2: setSignature
public function setSignature($path, $arr = array())
{
$nonce = time();
$url = $this->apiBase . $path;
$message = $nonce . $url . http_build_query($arr);
$signature = hash_hmac("sha256", $message, $this->secretKey);
$this->client->setDefaultOption('headers/ACCESS-NONCE', $nonce);
$this->client->setDefaultOption('headers/ACCESS-SIGNATURE', $signature);
}
示例3: logOnClient
/**
* Authenticate to the API
*
* @return boolean
*/
private function logOnClient()
{
$logOnRequest = new LogOnRequest();
$logOnRequest->UserName = $this->config->getUserName();
$logOnRequest->Password = $this->config->getPassword();
$LogOnResponse = $this->client->logOn($logOnRequest->jsonSerialize());
if ($LogOnResponse->IsSuccess) {
$this->setHeader('SecurityToken', $LogOnResponse->SecurityToken);
$this->client->setDefaultOption('headers', $this->getHeaders());
return true;
} else {
return false;
}
}
示例4: execute
/**
* Performs the API Call to PostMarkApp using GuzzlePHP
*
* @param $type
*
* @return string
*/
private function execute($type)
{
$client = new Client($this->_api_url);
$client->setDefaultOption("headers", array('X-Postmark-Server-Token' => $this->_credentials, 'Accept' => 'application/json', 'Content-Type' => ' application/json'));
$url = "";
switch ($type) {
case "SEND":
$url = $this->_api_send_url;
break;
case "BATCH":
$url = $this->_api_batch_url;
}
$request = $client->post($url, null, json_encode($this->_send_object));
return $request->send()->json();
}
示例5: getClient
/**
* Get guzzle client
* @return Client
*/
public function getClient()
{
if ($this->client instanceof Client) {
return $this->client;
}
$client = new Client();
$client->setDefaultOption('verify', false);
return $client;
}
示例6: docUploadTestAction
public function docUploadTestAction()
{
$client = new Client('https://lossync.sudoux.com/losService.svc', array('ssl.certificate_authority' => false));
$client->setDefaultOption('auth', array('dan', 'letmein!789', 'Basic'));
/*$user = array(
'AuthUser' => array(
'uri' => 'https://lossync.sudoux.com/losService.svc',
'username' => 'dan',
'password' =>
),
'lostype' => 0,
'apiKey' => 'AAKLPCALBX',
);*/
$filePath = $this->container->get('kernel')->getRootDir() . '/../web/fff.jpg';
if (!is_file($filePath)) {
$e = new \Exception('Local file not found');
$this->logger->crit($e->getMessage());
throw $e;
}
// first upload the file
$params = array('file' => '@' . $filePath);
// $request = $client->post('uploadFile');
// Set the body of the POST to stream the contents of /path/to/large_body.txt
// $request->setBody(fopen('/path/to/large_body.txt', 'r'));
// $response = $request->send();
$request = $client->post('uploadFile');
$request->setBody(fopen($filePath, 'r'));
$response = $request->send();
$data = $response->json();
}
示例7: setAcceptLanguage
public function setAcceptLanguage($value)
{
$this->client->setDefaultOption('headers/Accept-Language', $value);
}
示例8: setDefaultOption
/**
* @param string $keyOrPath
* @param mixed $value
*
* @return $this
*/
public function setDefaultOption($keyOrPath, $value)
{
return parent::setDefaultOption($keyOrPath, $value);
}