Ruby的HTTP/REST客户端库 HTTParty

码农软件 · 软件分类 · REST/RESTful项目 · 2019-03-11 16:14:14

软件介绍

HTTParty是目前最受Ruby爱好者欢迎的一个简单的HTTP / REST客户端库。

示例代码:

 

require 'rubygems'

require 'httparty'

 

class Representative

  include HTTParty

  base_uri 'whoismyrepresentative.com'

  default_params :output => 'json'

  format :json

 

  def self.find_by_zip(zip)

    get('/whoismyrep.php', :query => {:zip => zip})

  end

 

  def self.get_all_by_name(last_name)

    get('/getall_reps_byname.php', :query => {:lastname => last_name})

  end

end

 

puts Representative.get_all_by_name('Donnelly').inspect

# {"results"=>[{"district"=>"2", "last"=>"Donnelly", "first"=>"Joe", "state"=>"IN", "party"=>"D"}]}

 

本文地址:https://codercto.com/soft/d/1122.html

JavaScript: The Definitive Guide, 5th Edition

JavaScript: The Definitive Guide, 5th Edition

David Flanagan / O'Reilly Media / 2006-08-01 / USD 49.99

This Fifth Edition is completely revised and expanded to cover JavaScript as it is used in today's Web 2.0 applications. This book is both an example-driven programmer's guide and a keep-on-your-desk ......一起来看看 《JavaScript: The Definitive Guide, 5th Edition》 这本书的介绍吧!

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具