当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::curlOpt方法代码示例

本文整理汇总了PHP中Unirest\Request::curlOpt方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::curlOpt方法的具体用法?PHP Request::curlOpt怎么用?PHP Request::curlOpt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Unirest\Request的用法示例。


在下文中一共展示了Request::curlOpt方法的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();
 }
开发者ID:RusinovIG,项目名称:unirest-php,代码行数:7,代码来源:RequestTest.php

示例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;
 }
开发者ID:phpkg,项目名称:wechat-pay,代码行数:39,代码来源:Payment.php


注:本文中的Unirest\Request::curlOpt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。