Skip to content

Instantly share code, notes, and snippets.

@adatta02
Created October 19, 2011 23:44
Show Gist options
  • Save adatta02/1300012 to your computer and use it in GitHub Desktop.
Save adatta02/1300012 to your computer and use it in GitHub Desktop.
tru.ly social API PHP sample
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST'){
$sig = urldecode( $_REQUEST["signature"] );
$data = urldecode( $_REQUEST["data"] );
// TODO: REPLACE THIS WITH YOUR SECRET
$secret = "9ffd989277b2058efe0542aff08c9301dc9fd9ce";
$expected_sig = hash_hmac('sha256', $data, $secret, false);
$error = null;
// signature didn't match so don't trust the data
if ($sig !== $expected_sig) {
$error = "INVALID SIGNATURE!";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment