PHP
<!DOCTYPE html>
<html>
<body>
<?php
function hex2bin( $hex ) { /* only needed for PHP < 5.4 */
return pack('H*', $hex);
}
function execRFG_API( $command ) {
/* put your APID and SECRET below */
$apid = '';
$secret = '';
/* do not modify below */
$key = hex2bin($secret);
$tm=time();
$hash = hash_hmac("sha1",$tm.$command,$key);
$api_url = "https://api.researchforgood.com/API?apid=$apid&time=$tm&hash=$hash";
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $command);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($command))
);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
echo execRFG_API( '{ "command" : "test/copy/1" , "data1" : "THIS IS A TEST"}' );
?>
</body>
</html>