weblabnl/restclient

1.0.2 2018-05-08 11:34 UTC

This package is not auto-updated.

Last update: 2024-09-23 16:11:36 UTC


README

此库可以帮助您更快地实现REST API。只需添加一个实现接口的适配器,设置基本URL,即可开始使用。它附带了一个OAuth适配器。

安装

使用composer安装

composer require weblabnl/restclient

使用库

设置客户端

$api = new \Weblab\RESTClient\RESTClient();

$adapter = (new \Weblab\RESTClient\Adapters\OAuth)
    ->setAccessToken($accessToken);

$api->setAdapter($adapter);
$api->setBaseURL('https://api.weblab.nl');

向REST API发送POST请求

$result = $api->post('/users', ['first_name' => 'Ankie', 'last_name' => 'Visser']);