Manage your status pages with the PHP SDK
Make sure you've read the getting started guide first. Once that's done, you should have our package & authentication ready to go.
Retrieve all status pages
The simplest example is one where we list all your status pages that have been configured.
$statusPages = $ohDear->statusPages();
This will return an array of OhDear\PhpSdk\Resources\StatusPage
instances.
The individual attributes will be explained in the next section.
Retrieve the status of a single status page
The simplest example is one where we get the details of a single status page that has been configured. Below, we'll retrieve the status page with the ID of 1.
$statusPage = $ohDear->statusPage(1);
This will return an instance of OhDear\PhpSdk\Resources\StatusPage
.
You can get a few properties of a Status Page.
$statusPage->id;
$statusPage->title;
$statusPage->attributes->sites; /* Array of sites */
$statusPage->attributes->updates; /* Array of update message */
$statusPage->summarized_status;
...
For more extensive understanding of the return values, please have a look at our status page API documentation.
Retrieve all status page updates
The simplest example is one where we list all the updates for a status page.
$ohDear->statusPage(1)->updates();
// Alternatively you could do this
$statusPages = $ohDear->statusPageUpdates(1);
This will return an array of OhDear\PhpSdk\Resources\StatusPageUpdate
instances.
The individual attributes will be explained in the next section.
Add a status page update through the SDK
A new status page update can be created with createStatusPageUpdate()
.
$statusPageUpdate = $ohDear->createStatusPageUpdate([
'status_page_id' => 1,
'title' => 'Our site is down',
'text' => 'We are working on it!',
'pinned' => true,
'severity' => 'high', // One of: info, warning, high, resolved, scheduled
'time' => '2021-02-09 12:25', // A UTC date field for this update in the Y-m-d H:i format
]);
This will return an instance of OhDear\PhpSdk\Resources\StatusPageUpdate
You can get a few properties of a Status Page Update.
$statusPageUpdate->id;
$statusPageUpdate->title;
$statusPageUpdate->text;
$statusPageUpdate->pinned;
$statusPageUpdate->severity;
$statusPageUpdate->time;
$statusPageUpdate->statusPageUrl;
Deleting a status page update
A site can easily be deleted. This assumes the $statusPageUpdate
is an instance of OhDear\PhpSdk\Resources\StatusPageUpdate
, which you can get with the statusPageUpdates()
method.
$statusPageUpdate->delete();
// Alternatively you could do this
$ohDear->deleteStatusPageUpdate(1);
For more extensive understanding of the return values, please have a look at our status page updates API documentation.
Was this page helpful to you? Feel free to reach out via support@ohdear.app or on Twitter via @OhDearApp if you have any other questions. We'd love to help!