This example uses PHP's curl bindings to make a request to the Opalstack API. It is adapted from an example found [here](https://weichie.com/blog/curl-api-calls-with-php/. I don't use PHP much myself so there are probably other/better ways to do this.
<?php
$token = 'YOUR_TOKEN_HERE';
$url = 'https://my.opalstack.com/api/v1/osuser/list/';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Authorization: Token '.$token,
'Content-Type: application/json',
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$result = curl_exec($curl);
if(!$result){die("Connection Failure");}
curl_close($curl);
echo $result;
The output will be the JSON returned by the API call.
You can adapt this to other API calls by changing the value of $url
near the top of the script, eg:
- Apps:
$url = 'https://my.opalstack.com/api/v1/app/list/';
- Mailboxes:
$url = 'https://my.opalstack.com/api/v1/mailuser/list/';
- Email addresses:
$url = 'https://my.opalstack.com/api/v1/address/list/';