简化版 / http
独立的PSR7实现的HTTP客户端
0.0.12
2018-05-07 15:29 UTC
Requires
- php: >=7.1
- php-http/client-common: ^1.0
- php-http/curl-client: ^1.7
- php-http/guzzle6-adapter: ^1.1
README
_ _ _ _ _ ___(_)_ __ ___ _ __ | | ___ _ __ | |__ | |_| |_ _ __ / __| | '_ ` _ \| '_ \| |/ _ \| '_ \ | '_ \| __| __| '_ \ \__ \ | | | | | | |_) | | (_) | | | | | | | | |_| |_| |_) | |___/_|_| |_| |_| .__/|_|\___/|_| |_| |_| |_|\__|\__| .__/ |_| |_|
示例
use Psr\Http\Message\ResponseInterface; use Simplon\Http\Adapter\GuzzleHttp; use Simplon\Http\HttpInterface; use Simplon\Http\Strategies\JsonRequestStrategy; // // some class // class SomeHttp { /** * @var HttpInterface */ private $http; /** * @param HttpInterface $http */ public function __construct(HttpInterface $http) { $this->http = $http; } /** * @return ResponseInterface * @throws Exception * @throws \Http\Client\Exception */ public function register(): ResponseInterface { $request = $this->http->buildRequest('POST', 'http://someapi.com/1.0/register'); JsonRequestStrategy::create($request, ['token' => '00RVS2CI7K1S']); return $this->http->sendRequest($request); } } $foo = new SomeHttp(new GuzzleHttp()); $response = $foo->register(); // // print response // var_dump($response->getBody()->getContents());
许可证
Cirrus 在MIT许可证的条款下免费分发。
版权(c)2017 Tino Ehrich(《tino@bigpun.me》)
特此授予任何获得此软件及其相关文档副本(“软件”)的人免费使用、复制、修改、合并、发布、分发、再许可和/或销售副本的权利,并允许获得软件的人这样做,但受以下条件约束:
上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。
本软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、针对特定目的的适用性和非侵权性保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任负责,无论该责任是基于合同、侵权或其他方式,无论是源于、由或与该软件或其使用或其他交易相关。