PHP
<?php
$entrypoint = 'https://www.lingkapis.com';
$apikey = '[your key]';
$secret = '[your secret]';
$studentdata = servicecall('/v1/@self/ps/students', "", "GET");
function servicecall($service, $querystring, $method) {
global $entrypoint, $apikey, $secret;
$timestamp = gmdate('D, d M Y H:i:s \U\T\C', time());
$message = "date: $timestamp\n(request-target): ".strtolower($method)." ".$service;
$signature = base64_encode(hash_hmac('sha1', $message, $secret, true));
$url = $entrypoint . $service . $querystring;
$dateheader = 'Date: '."$timestamp";
$authheader = 'Authorization: Signature keyId="'.$apikey.'",algorithm="hmac-sha1",headers="date (request-target)",signature="'.urlencode($signature).'"';
echo 'curl -n';
echo " -H \"".$dateheader.'"';
echo " -H \"".$authheader.'"';
echo " ".$url;
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
$dateheader,
$authheader
));
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
?>
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo $studentdata; ?>
</body>
</html>
Last updated