Skip to content

Instantly share code, notes, and snippets.

@gavinr
Created March 25, 2011 14:05
Show Gist options
  • Save gavinr/886876 to your computer and use it in GitHub Desktop.
Save gavinr/886876 to your computer and use it in GitHub Desktop.
Ravelry API signing example php
<?php
// Shh keep this secret:
$secret = '1111111111111111111111111111111111111111';
$data = array();
$data['access_key'] = '00000000000000000000';
$data['query'] = 'yarn me'; // for example
$data['shop_type_id'] = '1'; // for example
$data['timestamp'] = date('c'); // ISO8601 format
$string = 'http://api.ravelry.com' . '/shops/search.json?' . http_build_query($data);
$signature = base64_encode(hash_hmac('sha256', $string, $secret));
$data['signature'] = $signature;
$final = http_build_query($data);
$final = 'http://api.ravelry.com' . '/shops/search.json?' . $final;
echo '<pre>' . $final . '</pre>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment