The following example is API ‘list-gpu’ call:
<?php
$apiKey = '<YOUR_API_KEY>';
$apiSecret = '<YOUR_SECRET>';
$fullURLString = 'https://ul-benchmarks.appspot.com/api/list-gpu';
$options = array(
'key' => $apiSecret,
'keyId' => $apiKey,
'algorithm' => 'hmac-sha1');
$options['headers'] = array('(request-target) date', 'nonce');
$forNonce = date_timestamp_get(new Datetime("now"));
$headers['nonce'] = $forNonce;
$sign = array();
$data = join("\n", $sign);
$signatureString = "(request-target): get /api/list-gpu date: " . strval($forNonce);
$signature = hash_hmac('sha1',
$signatureString, $options['key']);
$final = 'Signature keyId="' . $options['keyId'] . '",algorithm="hmac-sha1"' . ',headers="(request-target)
date"' . ',nonce="' . strval($forNonce) . '",signature="' . $signature . '"';
/*echo "Sample authorization: " .
'Signature
keyId="623dc04f515644d89ea9b3944488cd03",algorithm="hmac-sha1",headers="(request-target)
date",nonce="1619103273",signature="9da04b2be4de94de02150d3b60ce488c6a30d42f"' .
"</br>";
echo "Sent signatureString: " . $signatureString .
"</br>";
echo "Sent signature: " . $signature .
"</br>";
echo "Sent authorization: " . $final .
"</br>";*/
$headers['authorization'] = $final;
$http_headers = array();
foreach ($headers as $k => $v) {
$http_headers[] = "$k: $v";
}
$http_headers[]
= "accept:
application/json";
$http_headers[]
= "X-Api-Key: $apiKey";
$ch = curl_init($fullURLString);
curl_setopt($ch, CURLOPT_HTTPHEADER, $http_headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($ch);
$err = curl_error($ch);
if ($err) {
echo "<p>" . $err . "</p>";
}
echo "<p>" . $response . "</p>";
curl_close($ch);
?>
Output looks like the structure below:
[
{
"name":
"2x AMD Radeon RX 460",
"type":
"desktop"
},
...
]
The following example is API ‘estimate’ call:
<?php
$apiKey = '<YOUR_API_KEY>';
$apiSecret = '<YOUR_SECRET>';
$fullURLString = 'https://ul-benchmarks.appspot.com/api/estimate';
$options = array(
'key' => $apiSecret,
'keyId' => $apiKey,
'algorithm' => 'hmac-sha1');
$forNonce = date_timestamp_get(new Datetime("now"));
$headers['nonce'] = $forNonce;
$sign = array();
$data = join("\n", $sign);
$signatureString = "(request-target): post /api/estimate date: " . strval($forNonce);
$signature = hash_hmac('sha1',
$signatureString, $options['key']);
$final = 'Signature keyId="' . $options['keyId'] . '",algorithm="hmac-sha1"' . ',headers="(request-target)
date"' . ',nonce="' . strval($forNonce) . '",signature="' . $signature . '"';
/*echo "Sample authorization: " .
'Signature
keyId="623dc04f515644d89ea9b3944488cd03",algorithm="hmac-sha1",headers="(request-target)
date",nonce="1619103273",signature="9da04b2be4de94de02150d3b60ce488c6a30d42f"' .
"</br>";
echo "Sent signatureString: " . $signatureString .
"</br>";
echo "Sent signature: " . $signature .
"</br>";
echo "Sent authorization: " . $final .
"</br>";*/
$headers['authorization'] = $final;
$http_headers = array();
foreach ($headers as $k => $v) {
$http_headers[] = "$k: $v";
}
$http_headers[]
= "Content-Type:
application/json";
$http_headers[]
= "X-Api-Key: $apiKey";
$request = [
"cpuName" => "2x Intel Xeon Processor E5-2640 v4",
"gpuName" => "2x AMD Radeon RX 460",
"cpuOC" => "1",
"gpuNumber" => "1",
"gpuType" => "desktop",
"memchannels" => 2,
"memfrequency" => 2400
];
$postdata = json_encode($request);
$ch = curl_init($fullURLString);
curl_setopt($ch, CURLOPT_HTTPHEADER, $http_headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POST, 1);
$response = curl_exec($ch);
$err = curl_error($ch);
if ($err) {
echo "<p>" . $err . "</p>";
}
echo "<p>" . $response . "</p>";
curl_close($ch);
?>
Output looks like the structure below:
{
"timeSpyScoreGPU":
3436,
"timeSpyScoreCPU":
6300,
"timeSpyOverallScore": 3687,
"gameTitles":
{
"Cyberpunk 2077": {
"fullHdFps": "35",
"quadHdFps": "less than 20"
},
"Fortnite": {
"fullHdFps": "145",
"quadHdFps": "40"
},
}
}