Created
August 15, 2014 13:14
-
-
Save iperdomo/e6e67ad1ebf7a306ada0 to your computer and use it in GitHub Desktop.
Sample code for FLOW API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <? | |
| // 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