Interface for StatusCake API
Open Issues: 3
- php: >=5.3.3
This package is auto-updated.
Last update: 2023-03-09 17:17:05 UTC
#StatusCake API wrapper
StatusCake is a monitoring service that monitors website/servers over HTTP/TCP/PING.
This project wraps most endpoints StatusCake has to offer.
composer require happydemon/statuscake
Setting up the client:
$statusCake = new StatusCake\Client(`USER', 'TOKEN');
Checking if the credentials are valid:
$statusCake->validAccount(); // return true or false
Getting basic account info:
These are actually your monitors, each test would represent a website you're monitoring.
Each returned test will be parsed into a class
StatusCake\Test, all the properties are documented in there, be sure to check it out.
Creating a test
To create a test you need to initialise
StatusCake\Test. There are just a few properties that are actually required; websiteName, websiteURL, testType.
$test = new StatusCake\Test(); // Required parameters $test->websiteName = 'HappyDemon'; $test->websiteURL = 'http://happydemon.xyz'; $test->testType = StatusCake\Test::TYPE_HTTP; // I'm a little impatient, so I'd like more frequest checks (every 2 minutes) $test->checkRate = 120; // Save everything $statusCake->updateTest($test);
Updating a test
Updating is done in the same way:
// I've changed my mind, let's check every 5 minutes $test->checkRate = 300; // Save the change $statusCake->updateTest($test);
Deleting a test
Retrieving a list of existing tests is simple:
$tests = $statusCake->getTests();
Retrieving a test's period
A period of data is two time stamps in which status has remained the same.
$periods = $test->getPeriods();
Retrieving a test's performance data
Retrieves a list of checks performed for the current site (this statusCake users with a premium account).
$periods = $test->getPerformance();
Retrieve a test's previously sent alerts
Retrieves a list of alerts that have, previously, been sent.
$periods = $test->getAlerts();
One of the properties tests could need assigned is contact groups. You can retrieve and manage them through the API as wel.
The same principles as Tests are applied here, meaning every contact group will be loaded in a
StatusCake\ContactGroup class (check the class definition for more info on the properties).
A few helper functions are included to work with email addresses.
Creating a contact group
$contactGroup = new StatusCake\ContactGroup(); // The only required parameter $contactGroup->groupName = 'personal mail'; // let's add an email to get notifications $contactGroup->addEmail('firstname.lastname@example.org'); // Save everything $statusCake->updateContactGroup($contactGroup);
Updating a contact group
// I've changed my mind, different email $contactGroup->removeEmail('email@example.com'); $contactGroup->addEmail('firstname.lastname@example.org'); // Which is the same as doing $contactGroup->email = ['email@example.com'] // Save everything $statusCake->updateContactGroup($contactGroup);
Deleting a contact group