Webをキャプチャして変換するツール

Perlを使用したGrabzItハンドラー

Perl API

説明

ハンドラーのデバッグに問題がありますか? 試してみて コールバックハンドラーテストツール。

ここで説明するハンドラーは、GrabzItスクリーンショットWebサービスからのコールバックを処理します。 このハンドラーのURLは、GrabzItに渡されます callBackURL のパラメータ Save 方法。 ただし、この手法は、ハンドラーが Internet。

次のパラメーターは、GETパラメーターとしてハンドラーに渡されます。

GrabzItを除き、ハンドラーへのすべてのアクセスをブロックする場合は、これを使用します セキュリティ技術.

アプリケーションがローカルホストにある場合、このコールバックは機能しません。

この例は、GrabzIt Perl ハンドラーを実装する方法を示しています。これにより、GrabzIt サービスから渡される 6 つのパラメータがキャプチャされます。これには、 GetResult 方法。

次に、このメソッドはスクリーンショットを返します。 save結果ディレクトリ内のd。 ただし、 null 値はから返されます GetResult メソッドは、エラーが発生したことを示します。

use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser); 
use File::Spec;
use GrabzIt::GrabzItClient;

# This Perl file handles the GrabzIt callback

print "HTTP/1.0 200 OK";
print "Content-type: text/html\r\n\r\n";

$cgi = new CGI;

$message = $cgi->param("message");
$customId = $cgi->param("customid");
$id = $cgi->param("id");
$filename = $cgi->param("filename");
$format = $cgi->param("format");
$targetError = $cgi->param("targeterror");

# Custom id can be used to store user ids or whatever is needed for the later processing of the
# resulting screenshot

$grabzIt = new GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")%>");
$result = $grabzIt->GetResult($id);

if ($result)
{
        # Ensure that the application has the correct rights for this directory.
        open FILE, ">".File::Spec->catfile("results",$filename) or die $!; 
        binmode FILE;
        print FILE $result; 
        close FILE;
}