A set of scripts to get data from 42's API
This library uses Composer to manage its dependencies, so Install Composer.
cd
to the project's folder and run:
composer install
You first need to Register a new app to get your credentials.
Rename .env.example
to .env
and fill it with your details.
You can take a look at script_template
for a quick example.
To send a POST request use:
$body = ['key' => 'value'];
$response = $intraRequest->post('/api/uri', $body);
To send a GET request use:
$parameter = ['key' => 'value'];
$response = $intraRequest->get('/api/uri', $parameter);
The $response
contains the raw text, so if you want to use it you will probably need to decode it:
$response = json_decode($response);