ckdarby/php-uptimerobot

UptimeRobot.com API 的 PHP 包装器

v0.2.0 2018-02-27 14:58 UTC

This package is auto-updated.

Last update: 2024-09-21 19:42:00 UTC


README

这是一个针对 https://uptimerobot.com/api 的基本 PHP 包装器

先决条件

  • 配置 $config apiKey
  • 必须运行 PHP >= 5.4
  • 格式将为 JSON,并且不会有 JSONCallback

Composer

将以下内容添加到您的 composer.json 中

{
    "require": {
        "ckdarby/php-uptimerobot": "@stable"
    }
}

示例

<?php
//Requires composer install to work
require_once(__DIR__.'/vendor/autoload.php');

use UptimeRobot\API;

//Set configuration settings
$config = [
    'apiKey' => 'APIKEY',
    'url' => 'https://api.uptimerobot.com'
];

try {

    //Initalizes API with config options
    $api = new API($config);

    //Define parameters for our getMethod request
    $args = [
        'showTimezone' => 1
    ];

    //Makes request to the getMonitor Method
    $results = $api->request('/getMonitors', $args);

    //Output json_decoded contents
    var_dump($results);

} catch (Exception $e) {
    echo $e->getMessage();
    //Output various debug information
    var_dump($api->debug);
}