捕获和转换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