ここで説明するハンドラーは、GrabzItスクリーンショットWebサービスからのコールバックを処理します。 このハンドラーのURLは、GrabzItに渡されます callBackURL
のパラメータ Save 方法。
ただし、この手法は、ハンドラーが Internet。
次のパラメーターは、GETパラメーターとしてハンドラーに渡されます。
GrabzItを除き、ハンドラーへのすべてのアクセスをブロックする場合は、これを使用します セキュリティ技術.
この例は、GrabzIt Pythonハンドラーの実装方法を示しています。 これは、GrabzItサービスから渡された5つのパラメーターをキャプチャします。これには、に渡されるスクリーンショットの一意のIDが含まれます GetResult 方法。
次に、このメソッドはスクリーンショットを返します。 save結果ディレクトリ内のd。 ただし、 null
値はから返されます GetResult メソッドは、エラーが発生したことを示します。
import os import cgi from GrabzIt import GrabzItClient from ConfigParser import SafeConfigParser form = cgi.FieldStorage() message = form.getvalue("message") customId = form.getvalue("customid") id = form.getvalue("id") filename = form.getvalue("filename") format = form.getvalue("format") targeterror = form.getvalue("targeterror") # Custom id can be used to store user ids or whatever is needed for the later processing of the # resulting screenshot grabzIt = GrabzItClient.GrabzItClient("Sign in to view your Application Key", "Sign in to view your Application Secret")%>") result = grabzIt.GetResult(id) if result != None: # Ensure that the application has the correct rights for this directory. fo = open("results" + os.sep + filename, "wb") fo.write(result) fo.close() print "Status: 200 OK" print