Perl で reCAPTCHA を使用する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
重要: reCAPTCHA API のバージョン 1.0 のサポートは終了しました。バージョン 2.0 にアップグレードしてください。詳細
reCAPTCHA Perl モジュールを使用すると、簡単に CAPTCHA を配置できます。
bot による悪用を阻止できます。このモジュールは、
reCAPTCHA API。
Perl で reCAPTCHA を使用するには、reCAPTCHA Perl を
Module(Andy Armstrong 寄稿)。このモジュールは、ローカルマシン上で
構成されます。このモジュールは、LWP::UserAgent モジュールに依存します。
と HTML::Tiny があります。どちらも
これもインストールする必要がありますPerl のインストールに関する基本的な手順は、こちら
モジュールをご覧ください。
クイック スタート
API キーに登録して reCAPTCHA Perl モジュールをダウンロードしたら、以下の基本的な手順を実施します。
reCAPTCHA をサイトにインストールします。
クライアントサイド(CAPTCHA 画像の表示方法)
Perl モジュールを使用して reCAPTCHA ウィジェットを表示する場合は、
この行は、reCAPTCHA ウィジェットが追加されるフォーム要素を含むファイルの先頭付近にあります。
表示:
use Captcha::reCAPTCHA;
次に、reCAPTCHA のインスタンスを作成します。
my $c = Captcha::reCAPTCHA->new;
最後に、reCAPTCHA ウィジェットを表示するには、
<form>タグ:
print $c->get_html("your_public_key");
コードは次のようになります。
use Captcha::reCAPTCHA;
my $c = Captcha::reCAPTCHA->new;
print <<EOT;
<html>
<body>
<form action="" method="post">
EOT
print $c->get_html("your_public_key");
print <<EOT;
<input type="submit" value="submit" />
</form>
</body>
</html>
EOT
your_public_key
は、実際の値で置き換えてください。
API キー。
サーバーサイド(ユーザーが正しい回答を入力したかどうかをテストする方法)
以下は、reCAPTCHA の回答を検証する方法のスケルトンです。
use Captcha::reCAPTCHA;
my $c = Captcha::reCAPTCHA->new;
my $challenge = param 'recaptcha_challenge_field';
my $response = param 'recaptcha_response_field';
# Verify submission
my $result = $c->check_answer(
"your_private_key", $ENV{'REMOTE_ADDR'},
$challenge, $response
);
if ( $result->{is_valid} ) {
print "Yes!";
}
else {
# Error
print "No";
}
関連情報
デザインのカスタマイズ
ヒントとガイドライン
トラブルシューティング
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
最終更新日 2024-09-09 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2024-09-09 UTC。"],[[["reCAPTCHA v1.0 is no longer supported; users should upgrade to v2.0."],["The reCAPTCHA Perl Module helps prevent bot abuse on websites by incorporating CAPTCHAs."],["This module requires installation along with the LWP::UserAgent and HTML::Tiny modules."],["Implementation involves client-side code to display the reCAPTCHA widget and server-side code to verify user responses."],["Detailed instructions and further resources are available for customization, tips, and troubleshooting."]]],["The reCAPTCHA Perl module enables website integration of CAPTCHAs to prevent bot abuse. It requires downloading and installing the module, along with `LWP::UserAgent` and `HTML::Tiny`. To display the CAPTCHA, use `use Captcha::reCAPTCHA`, create a reCAPTCHA instance, and use the `get_html` method with your public key. Server-side validation involves using `check_answer` with your private key, user IP address, challenge, and response, then checking the validity of the response.\n"]]