本文整理汇总了PHP中Unirest\Request::clearCurlOpts方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::clearCurlOpts方法的具体用法?PHP Request::clearCurlOpts怎么用?PHP Request::clearCurlOpts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Unirest\Request
的用法示例。
在下文中一共展示了Request::clearCurlOpts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCurlOpts
public function testCurlOpts()
{
Request::curlOpt(CURLOPT_COOKIE, 'foo=bar');
$response = Request::get('http://mockbin.com/request');
$this->assertTrue(property_exists($response->body->cookies, 'foo'));
Request::clearCurlOpts();
}
示例2: request
public function request($path, $params, $headers = [], $isSecure = false)
{
$params['appid'] = $this->options['appid'];
$params['mch_id'] = $this->options['mch_id'];
$params['nonce_str'] = $this->getNonce();
$params['sign'] = $this->sign($params);
$xml = $this->xmlEncode($params);
if ($isSecure) {
Request::curlOpt(CURLOPT_SSLCERTTYPE, 'PEM');
Request::curlOpt(CURLOPT_SSLCERT, $this->options['cert']);
Request::curlOpt(CURLOPT_SSLKEYTYPE, 'PEM');
Request::curlOpt(CURLOPT_SSLKEY, $this->options['private']);
}
/**
* @var $res \Unirest\Response
*/
$res = Request::post(sprintf('%s%s', $this->options['host'], $path), $headers, $xml);
if ($isSecure) {
Request::clearCurlOpts();
}
if ($res->code !== 200) {
throw new \Exception('Invalid response status code', $res->code);
}
$body = $this->xmlDecode($res->body);
if (!is_array($body)) {
throw new \Exception(sprintf('Invalid response body: %s', $res->body));
}
if ($body['return_code'] !== static::SUCCESS) {
throw new \Exception(sprintf('Invalid return_code: %s', $res->body));
}
if ($body['appid'] !== $this->options['appid'] || $body['mch_id'] !== $this->options['mch_id']) {
throw new \Exception(sprintf('Invalid appid or mch_id: %s', $res->body));
}
$sign = $body['sign'];
if ($sign !== $this->sign($body)) {
throw new \Exception(sprintf('Invalid sign: %s', $res->body));
}
return $body;
}