PHP code example of itjamie / pagerdutywhosoncall
1. Go to this page and download the library: Download itjamie/pagerdutywhosoncall library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
itjamie / pagerdutywhosoncall example snippets
date_default_timezone_set('UTC'); // set the timezone of your php env to be the same you pass to pagerduty
$pagerdutyapi = new PagerDutyWhosOncall(array(
'baseurl' => 'https://instancename.pagerduty.com/api/v1/',
'apikey' => 'placeholderforyourapi',
'debug' => false,
'timezone' => 'UTC' // This is the timezone that will be passed to pagerduty. https://developer.pagerduty.com/documentation/rest/types#timezone
)
);
$scheduleid = "abc123";
echo ' Oncall Now :'.PHP_EOL;
$result = $pagerdutyapi->whoIsOnCall( $scheduleid );
var_dump($result);
echo ' Oncall in one hour :'.PHP_EOL;
$time = time()+60*60;
$result = $pagerdutyapi->whoIsOnCall( $scheduleid, $time );
var_dump($result);