અહીં વર્ણવેલ હેન્ડલર ગ્રાબઝિટ સ્ક્રીનશ webટ વેબ સેવાથી ક fromલબેક્સ પર પ્રક્રિયા કરે છે. આ હેન્ડલરનો URL માં GrabzIt માં પસાર થાય છે callBackURL
ના પરિમાણ save પદ્ધતિ
જો કે આ તકનીક ફક્ત ત્યારે જ કાર્ય કરશે જ્યારે હેન્ડલર દ્વારા accessક્સેસ કરી શકાય Intએર્નેટ.
નીચેના પરિમાણો GET પરિમાણો તરીકે હેન્ડલરને પસાર કરવામાં આવે છે.
જો તમે GrabzIt સિવાય, હેન્ડલરની બધી blockક્સેસને અવરોધિત કરવા માંગતા હો, તો આનો ઉપયોગ કરો સુરક્ષા તકનીક.
આ ઉદાહરણ બતાવે છે કે કેવી રીતે ગ્રેબઝિટ રૂબી હેન્ડલર લાગુ કરી શકાય છે. આ GrabzIt સેવામાંથી તેને પસાર કરેલા પાંચ પરિમાણોને કેપ્ચર કરે છે, જેમાં સ્ક્રીનશોટની અનન્ય ID નો સમાવેશ થાય છે જે get_result પદ્ધતિ
આ પદ્ધતિ પછી સ્ક્રીનશોટ આપે છે, જે છે saveડી સ્ક્રીનશોટ ડિરેક્ટરીમાં. જો કે જો 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