Skip to content

Instantly share code, notes, and snippets.

@iperdomo
Created August 15, 2014 13:14
Show Gist options
  • Select an option

  • Save iperdomo/e6e67ad1ebf7a306ada0 to your computer and use it in GitHub Desktop.

Select an option

Save iperdomo/e6e67ad1ebf7a306ada0 to your computer and use it in GitHub Desktop.
Sample code for FLOW API
<?
// NOTE: requires php5-cli, php5-curl
$access_key = $argv[1];
$secret = $argv[2];
$url = $argv[3];
$date = time(); // UNIX timestamp
$resource = substr($url, strpos($url, "/api/v1"));
$res_parts = split("\?", $resource);
$payload = "GET\n$date\n" . $res_parts[0];
$signature = base64_encode(hash_hmac("sha1", $payload, $secret, TRUE));
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Date: $date", "Autorization: $access_key:$signature"));
curl_exec($curl);
curl_close($curl);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment