PHP code example of wtiservice / wti-service

1. Go to this page and download the library: Download wtiservice/wti-service 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/ */

    

wtiservice / wti-service example snippets


use wpiservice\WpiService\WpiService;

$wpiService = new WpiService();

$url = 'https://example.com';
$apiKey = 'your-api-key';

$result = $wpiService->Performance($url, $apiKey);

if (isset($result['error'])) {
    // Handle the error.
} else {
    // Use the performance data.
}

$performanceData = $wpiService->Performance($url, $apiKey);
$metricName = 'first-contentful-paint';

$metricData = $wpiService->PerformanceMetric($performanceData, $metricName);

if (isset($metricData['error'])) {
    // Handle the error.
} else {
    // Use the specific performance metric data.
}