ここで説明するハンドラーは、GrabzItスクリーンショットWebサービスからのコールバックを処理します。 このハンドラーのURLは、GrabzItに渡されます callBackURL
のパラメータ save 方法。
ただし、この手法は、ハンドラーが Internet。
次のパラメーターは、GETパラメーターとしてハンドラーに渡されます。
GrabzItを除き、ハンドラーへのすべてのアクセスをブロックする場合は、これを使用します セキュリティ技術.
この例は、GrabzIt Rubyハンドラーを実装する方法を示しています。 これは、GrabzItサービスから渡された5つのパラメーターをキャプチャします。これには、に渡されるスクリーンショットの一意のIDが含まれます get_result 方法。
次に、このメソッドはスクリーンショットを返します。 saveスクリーンショットディレクトリのd。 ただし、 nil
値はから返されます get_result メソッドは、エラーが発生したことを示します。
require 'grabzit' class HandlerController < ApplicationController def index message = params[:message] customId = params[:customid] id = params[:id] filename = params[:filename] format = params[:format] targetError = params[:targeterror] grabzItClient = GrabzIt::Client.new("Sign in to view your Application Key", "Sign in to view your Application Secret")%>") result = grabzItClient.get_result(id) if result == nil return end # Ensure that the application has the correct rights for this directory. screenshot = File.new("public/screenshots/"+filename, "wb") screenshot.write(result) screenshot.close end end