Last active
December 2, 2016 21:15
-
-
Save danhstevens/42dfd33960cf018afeb65e2328d89cea to your computer and use it in GitHub Desktop.
Kickbox Recipient Authentication Example PHP Scripts (Not for production use!)
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
<?php | |
$appCode = "YOUR_APP_CODE"; | |
$apiKey = "YOUR_API_KEY"; | |
$post = array('fingerprint' => $_POST['fingerprint'], 'apikey' => $apiKey); | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL,"https://api.kickbox.io/v2/authenticate/" . $appCode); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post)); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$output = curl_exec ($ch); | |
curl_close ($ch); | |
header('Content-type: application/json'); | |
echo $output; |
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
<!doctype html> | |
<head> | |
<title></title> | |
<meta name="description" content=""> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="css/bootstrap.min.css"> | |
<link rel="stylesheet" href="css/bootstrap-theme.min.css"> | |
<link rel="stylesheet" href="css/main.css"> | |
</head> | |
<body> | |
<div class="container"> | |
<form class="form-inline" id="form"> | |
<div class="form-group"> | |
<label class="sr-only" for="email">Email</label> | |
<input type="input" class="form-control" id="email" placeholder="Email"> | |
</div> | |
<button type="submit" class="btn btn-primary" id="subBtn">Submit</button> | |
</form> | |
<div id="tracker"></div> | |
</div> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> | |
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.11.2.min.js"><\/script>')</script> | |
<script src="js/vendor/bootstrap.min.js"></script> | |
<script type="text/javascript" src="https://kickbox.io/authenticate/1/release.js"></script> | |
<script src="main.js"></script> | |
</body> | |
</html> |
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
$('#form').submit(function(e) { | |
e.preventDefault(); // Stop browser form submission | |
var appCode = "YOUR_APP_CODE_HERE"; | |
var email = $('#email').val(); | |
Kickbox.fingerprint({ | |
app: appCode, | |
email: email, | |
onSuccess: function(fingerprint) { | |
$.post("_auth.php", { | |
email: email, | |
fingerprint: fingerprint | |
}, function(data){ | |
console.log(fingerprint, data); | |
Kickbox.track({ | |
app: appCode, | |
token: data.track_token, | |
element: $('#tracker')[0], | |
onProgress: function(response) {console.log(response);}, | |
onSuccess: function(response) {console.log(response);}, | |
onFailure: function(response) {console.log(response);}, | |
onError: function(error) {console.log(error);} | |
}); | |
}); | |
}, | |
onError: function(error) { | |
console.log(error.code); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment