PHP code example of jtl-software / opsgenie-client

1. Go to this page and download the library: Download jtl-software/opsgenie-client 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/ */

    

jtl-software / opsgenie-client example snippets


# named constructor to create a client (for EU)
$client = AlertApiClient::createForEUApi(getenv(UPSGENIE_TOKEN));

$alert = new Alert('eazyauction', 'test-alert', 'foo mag bär', 'beer-bar');
$response = $client->createAlert($alert);

if($response->isSuccessful()){
  
    // read our former created alert
    $alert = $client->getAlert(new GetAlertRequest($alert->getAlias()));

    // close our former created alert
    $client->closeAlert(new CloseAlertRequest($alert->getAlias()));
}

$token = "xxx-xxx-xxx";
$client = new HeartbeatApiClient(HttpClient::createForEUApi(getenv(UPSGENIE_TOKEN)));
do {
    $result = $client->sendPing(new PingRequest('beat'));
    var_dump($result, $result->isSuccessful());
    sleep(60);
} while(true);