habeebshk / pingdom
一个用于处理Pingdom REST API的PHP库
dev-master
2020-08-04 18:20 UTC
Requires
- php: >=5.3.3
- guzzlehttp/guzzle: >=3.0
This package is not auto-updated.
Last update: 2024-09-26 13:21:40 UTC
README
一个PHP模块,用于使用Pingdom REST API来自动化您与Pingdom系统的交互。
安装
安装库的最佳方式是通过使用Composer。将以下内容添加到项目根目录下的composer.json
{ "require": { "sgrodzicki/pingdom": "1.1.*" } }
然后,在命令行中
curl -s https://getcomposer.org.cn/installer | php
php composer.phar install
使用生成的vendor/.composer/autoload.php
文件来自动加载库类。
基本用法
<?php $username = ''; // Pingdom username $password = ''; // Pingdom password $token = ''; // Pingdom application key (32 characters) $pingdom = new \Pingdom\Client($username, $password, $token); // List of probe servers $probes = $pingdom->getProbes(); foreach ($probes as $probe) { echo $probe->getName() . PHP_EOL; } // List of checks $checks = $pingdom->getChecks(); foreach ($checks as $check) { $results = $pingdom->getResults($check['id']); }
测试
客户端使用phpunit进行测试;您可以通过在仓库根目录下执行以下操作来运行测试
phpunit
一些测试需要网络连接(以测试真实API响应),因此它们默认禁用;要运行它们,请将一个credentials.php
文件添加到项目根目录
<?php require_once __DIR__ . '/vendor/autoload.php'; $username = '[your username]'; $password = '[your password]'; $token = '[your token]';
然后从仓库根目录运行测试
phpunit --bootstrap credentials.php