Jump to content

captcha web API

- - - - -

  • Please log in to reply
10 replies to this topic

#1
debtboy

debtboy

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 916 posts
I know how everyone here loves APIs :bad:,
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:
<?

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>

Here is the sample script loaded:

Posted Image




This is after I entered the proper code:

Posted Image




This is after I entered an improper code:

Posted Image



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, ...

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Very cool and good to know! +rep

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Is that a free resource, or paid? As APIs go, it's pretty slick. +rep
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
debtboy

debtboy

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 916 posts
Yes 100% free

Thanks for the +rep

I think everyone hates spam!!
(the online version) the ham product is OK

#5
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
  • Location:New York, NY
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.

#6
debtboy

debtboy

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 916 posts

John said:

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.
No it doesn't offer advanced features,
so if one is willing to sign-up your recommendation
is much more feature rich.

#7
John

John

    Writes binary right handed and hex left handed

  • Moderators
  • 6,321 posts
  • Location:New York, NY
Yeah, it offers some nice features.

#8
BlaineSch

BlaineSch

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,448 posts
Sexy +Rep!

#9
Hajjel

Hajjel

    Newbie

  • Members
  • PipPip
  • 22 posts
Very useful, tnx!

#10
kailas

kailas

    Newbie

  • Members
  • PipPip
  • 17 posts
Many thanks!

#11
bason

bason

    Newbie

  • Members
  • PipPip
  • 13 posts
Great information thanks!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users