I know how everyone here loves APIs,
but I came across a web based API, that could
be very useful in certain situations.
A captcha - (login, designed to prevent automated spam
by offering a human readable image pattern which needs to
be keyed in for access).
This captcha API is made available with only a few lines of code.
I tried it, and it worked exactly as expected.
Here is the sample script:
Here is the sample script loaded:Code:<? session_start(); // You need a unique string that identifies the user. The easiest way is to // simply use the session ID. But because sending session IDs to other servers // can be a security problem, we use only a part of the session ID here. // This is still a quasi-unique string, so it works just as well. $captcha_id = substr(session_id(), 0, 15); // first 15 characters of the session ID ?> <html><head></head><body> <img src="http://captchator.com/captcha/image/<?= $captcha_id ?>" /> <br /> Please enter the text from the picture: <form action="test.php" method="post"> <input type="text" name="captcha_answer" /> <input type="submit" name="submit" value="Check" /> </form> <? if ($_POST['captcha_answer']) { // remove anything except letters and numbers (security) $answer = preg_replace('/[^a-z0-9]+/i', '', $_POST['captcha_answer']); // check answer // if you get an error message because your provider has diabled allow_url_fopen, // please use the myfile() function from the following website instead of file(): // http://www.klamm.de/crashforum/showpost.php?p=1041750&postcount=5 if (implode(file("http://captchator.com/captcha/check_answer/".$captcha_id."/".$answer)) == '1') { echo '<div style="color: green">Answer correct!</div>'; } else { echo '<div style="color: red">Wrong answer, please try again.</div>'; } } ?> <p> See the <a href="test.php.txt">source code</a> of this script. </p> </body></html>
This is after I entered the proper code:
This is after I entered an improper code:
No difficult code here, just a simple API which is easily incorporated.
Not for everyone, but in the right situation, it could be very helpful
in the never ending fight against spam prevention.
References:
Captchator - Captcha service for PHP, Ruby on Rails, Python, ...
Very cool and good to know! +rep
Is that a free resource, or paid? As APIs go, it's pretty slick. +rep
Yes 100% free
Thanks for the +rep
I think everyone hates spam!!
(the online version) the ham product is OK
Does it offer any more advanced features? I've been using and recommending reCaptcha for a while, as it offers things like refresh to generate a new image and audio too, but I'm always open to new API's.
Yeah, it offers some nice features.
Sexy +Rep!
Very useful, tnx!
Many thanks!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks