philcook/gtmetrix

PHP 的 GTMetrix API 客户端

v2.0.1 2021-02-17 13:05 UTC

This package is auto-updated.

Last update: 2024-09-19 05:45:21 UTC


README

Latest Stable Version Build Status Total Downloads License

安装

此客户端库可以使用 composer 安装

composer require philcook/gtmetrix

使用

use LightningStudio\GTMetrixClient\GTMetrixClient;
use LightningStudio\GTMetrixClient\GTMetrixTest;

$client = new GTMetrixClient();
$client->setUsername('your@email.com');
$client->setAPIKey('your-gtmetrix-api-key');

$client->getLocations();
$client->getBrowsers();
$test = $client->startTest('http://www.example.com/');
 
//Wait for result
while ($test->getState() != GTMetrixTest::STATE_COMPLETED &&
    $test->getState() != GTMetrixTest::STATE_ERROR) {
    $client->getTestStatus($test);
    sleep(5);
}

更新信息

从版本 2.0 开始,由于 Entrecore 已不存在,因此将 Entrecore 的引用替换为 LightningStudio,以避免用户产生混淆。