-
Notifications
You must be signed in to change notification settings - Fork 9
/
getWPT.php
48 lines (41 loc) · 1.77 KB
/
getWPT.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
function makeRequest($clientURL) {
$conn = new PDO("mysql:host={{HOSTNAME}};dbname={{DATABASE-NAME}}", {{USERNAME}}, "{{PASSWORD}}");
$conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$url="http://www.webpagetest.org/runtest.php?url=".$clientURL."&f=json&k={{ENTER API KEY HERE}}&fvonly=1&location=Dulles:Chrome.Cable&video=1";
$json = file_get_contents($url);
$obj = json_decode($json);
if ($obj->statusCode==400) {}
else {
$theUrl = $obj->data->jsonUrl;
$sql= $conn->prepare('INSERT INTO webpagetest (url, datetime, jsonUrl) VALUES (:url, NOW(), :jsonUrl)');
$sql->bindParam(':url', $clientURL);
$sql->bindParam(':jsonUrl', $theUrl);
$sql->execute();
}
$url="http://www.webpagetest.org/runtest.php?url=".$clientURL."&f=json&k={{ENTER API KEY HERE}}&fvonly=1&location=Chicago:Chrome.Cable&video=1";
$json = file_get_contents($url);
$obj = json_decode($json);
if ($obj->statusCode==400) {}
else {
$theUrl = $obj->data->jsonUrl;
$sql= $conn->prepare('INSERT INTO webpagetest (url, datetime, jsonUrl) VALUES (:url, NOW(), :jsonUrl)');
$sql->bindParam(':url', $clientURL);
$sql->bindParam(':jsonUrl', $theUrl);
$sql->execute();
}
$url="http://www.webpagetest.org/runtest.php?url=".$clientURL."&f=json&k={{ENTER API KEY HERE}}&fvonly=1&location=LosAngeles:Chrome.Cable&video=1";
$json = file_get_contents($url);
$obj = json_decode($json);
if ($obj->statusCode==400) {}
else {
$theUrl = $obj->data->jsonUrl;
$sql= $conn->prepare('INSERT INTO webpagetest (url, datetime, jsonUrl) VALUES (:url, NOW(), :jsonUrl)');
$sql->bindParam(':url', $clientURL);
$sql->bindParam(':jsonUrl', $theUrl);
$sql->execute();
}
}
makeRequest("http://mattshull.com/perf");
makeRequest("http://mattshull.com");
?>