An elegant and smart Rest API Client with OAuth2 authentication support. Build for Laravel and Someline Starter.
someline/rest-api-client is a Laravel package for an elegant and smart rest api client with oauth2 authentication support. build for laravel and someline starter..
It currently has 8 GitHub stars and 13.425 downloads on Packagist (latest version v1.2.4).
Install it with composer require someline/rest-api-client.
Discover more Laravel packages by someline
or browse all Laravel packages to compare alternatives.
Last updated
Someline Starter API Client is an elegant and smart Rest API Client with OAuth2 authentication support.
Build for Laravel and Someline Starter.
It can be used for accessing APIs created using Someline Starter framework.
Install composer package to your laravel project
composer require someline/rest-api-client
Add Service Provider to config/app.php
'providers' => [
...
Someline\Rest\RestClientServiceProvider::class,
...
],
Publishing config file.
php artisan vendor:publish
After published, config file for Rest Client is config/rest-client.php, you will need to config it to use Rest Client.
$restClient = new \Someline\Rest\RestClient('someline-starter');
$restClient->setOAuthUserCredentials([
'username' => '[email protected]',
'password' => 'Abc12345',
]);
$restClient->withOAuthTokenTypeUser();
$response = $restClient->get("users")->getResponse();
if (!$restClient->isResponseStatusCode(200)) {
$restClient->printResponseOriginContent();
$responseMessage = $restClient->getResponseMessage();
print_r($responseMessage);
} else {
$responseData = $restClient->getResponseData();
print_r($responseData);
}
phpunit
Please see CONTRIBUTING for details.
The MIT License (MIT). Please see License File for more information.