Created
January 7, 2014 20:28
-
-
Save raorao/8306320 to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
function slowApiLookup() { | |
try { | |
$url = "http://slowapi.com/delay/5.0"; | |
$curlSession = curl_init(); | |
curl_setopt($curlSession, CURLOPT_URL, $url); | |
curl_setopt($curlSession, CURLOPT_RETURNTRANSFER,1); | |
curl_setopt($curlSession, CURLOPT_TIMEOUT,1); | |
$response = curl_exec($curlSession); | |
} | |
catch (Exception $e) { | |
echo false; | |
}; | |
return $response; | |
// uncomment for mocking successful API requests | |
// return array("some property" => $response); | |
}; | |
require_once(__DIR__.'/km.php'); | |
$KM_KEY = 'some hex'; | |
KM::init("$KM_KEY"); | |
KM::identify('bob@bob.com'); | |
KM::record('Purchased', array( | |
'Product ID' => 'some id', | |
'Product Name' => 'some name', | |
'Price' => 'some price' | |
)); | |
$rapleaf = slowApiLookup(); | |
KM::set($rapleaf); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment