捕獲和轉換Web的工具

Ruby處理程序

Ruby API

產品描述

在調試處理程序時遇到問題嗎? 嘗試 回調處理程序測試工具。

此處描述的處理程序處理來自GrabzIt屏幕快照Web服務的回調。 該處理程序的URL在以下位置傳遞給GrabzIt: callBackURL 的參數 save 方法。 但是,只有在可以通過 Int以太網

以下參數作為GET參數傳遞給處理程序。

如果要阻止對處理程序的所有訪問,除了GrabzIt之外,請使用此方法 安全技術.

請記住,如果您的應用程序位於localhost上,則此回調將不起作用。

此範例展示如何實作 GrabzIt Ruby 處理程序。這會捕獲從 GrabzIt 服務傳遞給它的六個參數,包括傳遞給 get_result 方法。

然後,此方法返回屏幕截圖,即 saved在屏幕快照目錄中。 但是如果 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