Last active
August 29, 2015 14:12
-
-
Save robtuley/11222c4f7aeddf156f81 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 | |
session_start(); | |
$url = 'http://api.textcaptcha.com/example.json'; | |
$captcha = json_decode(file_get_contents($url),true); | |
if (!$captcha) { | |
$captcha = array( // fallback challenge | |
'question'=>'Is ice hot or cold?', | |
'answers'=>array(md5('cold')) | |
); | |
// + capture error info & log | |
} | |
// display question to user as part of form | |
echo htmlentities($captcha['question']); | |
// store answers in session | |
$_SESSION['captcha_ans'] = $captcha['answers']; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment