kfreiman / restful
基于 Guzzle 的客户端,用于 RESTful API
dev-master
2016-01-15 13:41 UTC
Requires
- guzzlehttp/guzzle: ^6.1
This package is not auto-updated.
Last update: 2024-09-18 18:45:34 UTC
README
它是一个以标准 RESTful API 为主要关注点的 HTTP 客户端。
## 关于 Guzzle 客户端的改进
用令牌替换 URI 中的参数
<?php require 'vendor/autoload.php'; $client = new \kfreiman\restful\RestfulClient( [ 'base_uri' => 'https://api.example.com/3.0/', 'headers' => [ 'Authorization' => 'Bearer my_token', ] ] ); $responce = $client->get('lists/{list_id}/user/{user_id}', [ 'list_id' => 123, 'user_id' => 1, ]); $result = $responce->getBody()->getContents(); var_dump($result); // user object