Skip to content

Instantly share code, notes, and snippets.

@miniplay
Last active December 13, 2015 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miniplay/4972189 to your computer and use it in GitHub Desktop.
Save miniplay/4972189 to your computer and use it in GitHub Desktop.
Miniplay S2S API: Signature validation for server 2 server callbacks (PHP)
<?php
$jsonString = file_get_contents("php://input"); /* Get the RAW POST DATA */
if ( ! ( isset($_SERVER['HTTP_MINI_SIGNATURE'])
&& $_SERVER['HTTP_MINI_SIGNATURE'] == md5("[YOUR_API_KEY]".$jsonString) )) {
throw new Exception("Invalid signature");
}
/* the request signature has been validated! */
/* Decode the JSON string received and convert it to an associative array */
$json = json_decode($jsonString);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment