Laravel IDEABIZ Handler is a laravel plugin to handle REST API request for IDEABIZ APIs
- PHP 7.0+
- Laravel 8.0+
- Install the package by running this command in your terminal/cmd:
composer require dasun4u/laravel-ideabiz-handler
- You can import config file and sample token file by running this command in your terminal/cmd:
php artisan vendor:publish --provider="Dasun4u\LaravelIDEABIZHandler\RestAPIProvider"
-
Then set the configurations in ideabiz.php file.
-
For the first time, token generate using 'grant_type' => 'password' or manualy. Verify that token.json file has the valid access token and refresh token
It has following functions:
- Generate access token
IDEABIZ::generateAccessToken();
- Get access token
IDEABIZ::getAccessToken();
- Make the request
$access_token = IDEABIZ::getAccessToken();
$url = "https://ideabiz.lk/apicall/xyz"
$method = "POST";
$headers = [
"Content-Type" => "application/json",
"Authorization" => "Bearer ".$access_token,
"Accept" => "application/json",
];
$request_body = [
"a" => 123,
"b" => "xyz",
];
// Rest API request and response get to a variable
$response = IDEABIZ::apiCall($url, $method, $headers, $request_body);
// Get response body
$response->getBody();
// Get status code
$response->getStatusCode();
// Get response headers
$response->getHeaders();
This project is licensed under the MIT License - see the LICENSE file for details
- Laravel Community