Getting uptime reports for a site with our 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.
Getting uptime data
You can get uptime with the uptime()
method on a site. The method expects three parameters:
-
start
: a date in the form ofYmdHis
that determines the start of the range you want to get uptime for -
end
: a date in the form ofYmdHis
that determines the end of the range you want to get uptime for - split: a string that determines how fine grained the answer periods should be. Valid values are
hour
,day
andmonth
.
$ohDear->site($siteId)->uptime($start, $end, $split);
//alternatively you could do this
$ohDear->uptime($siteId, $start, $end, $split);
Both methods above will return an array of OhDear\PhpSdk\Resources\Uptime
instances. A Uptime
instance.
// The start of the period
$uptime->datetime;
// A float representing the percentage of time the site was up
$uptime->uptimePercentage;
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!