This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
commit 3101b5318b9476a9c7937f86581cddb623c820ee
tree 04ccd0e1846c9088e3df5b8f26679326fa44be56
parent fda012a3347d2633667e594015e94f119a341787
tree 04ccd0e1846c9088e3df5b8f26679326fa44be56
parent fda012a3347d2633667e594015e94f119a341787
httparty /
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Sun Jul 27 08:52:18 -0700 2008 | |
| |
History.txt | ||
| |
License.txt | Fri Dec 05 14:11:58 -0800 2008 | |
| |
Manifest.txt | Tue Jul 29 09:17:12 -0700 2008 | |
| |
PostInstall.txt | Mon Jul 28 13:48:22 -0700 2008 | |
| |
README.txt | Fri Oct 24 21:35:10 -0700 2008 | |
| |
Rakefile | Fri Oct 24 21:37:51 -0700 2008 | |
| |
config/ | Mon Jul 28 13:50:17 -0700 2008 | |
| |
examples/ | ||
| |
httparty.gemspec | ||
| |
lib/ | ||
| |
script/ | Mon Jul 28 07:49:53 -0700 2008 | |
| |
setup.rb | Sun Jul 27 08:52:18 -0700 2008 | |
| |
spec/ | ||
| |
tasks/ | Sat Aug 09 12:20:32 -0700 2008 | |
| |
website/ | Wed Jul 30 21:29:17 -0700 2008 |
README.txt
= httparty
== DESCRIPTION:
Makes http fun again!
== FEATURES/PROBLEMS:
* Easy get, post, put, delete requests
* Basic http authentication
* Default request query string parameters (ie: for api keys that are needed on each request)
* Automatic parsing of JSON and XML into ruby hashes based on response content-type
== SYNOPSIS:
The following is a simple example of wrapping Twitter's API for posting updates.
class Twitter
include HTTParty
base_uri 'twitter.com'
basic_auth 'username', 'password'
end
Twitter.post('/statuses/update.json', :query => {:status => "It's an HTTParty and everyone is invited!"})
That is really it! The object returned is a ruby hash that is decoded from Twitter's json response. JSON parsing is used
because of the .json extension in the path of the request. You can also explicitly set a format (see the examples).
That works and all but what if you don't want to embed your username and password in the class? Below is an example to
fix that:
class Twitter
include HTTParty
base_uri 'twitter.com'
def initialize(u, p)
@auth = {:username => u, :password => p}
end
def post(text)
options = { :query => {:status => text}, :basic_auth => @auth }
self.class.post('/statuses/update.json', options)
end
end
Twitter.new('username', 'password').post("It's an HTTParty and everyone is invited!")
=== REQUEST OPTIONS
Each of the HTTP method (get, post, put and delete) each take a hash of options.
The following keys can be specified in the options:
headers:: A <tt>Hash</tt> of header key/value pairs
query:: A <tt>Hash</tt> of query key/value pairs
body:: The body of the request. If it's a <tt>Hash</tt>, it is
converted into query-string format, otherwise it is sent
as-is.
basic_auth:: A <tt>Hash</tt> containing keys for <tt>:username</tt> and
<tt>:password</tt>.
no_follow:: Turns off automatic redirect following
== REQUIREMENTS:
* Active Support >= 2.1
== INSTALL:
* sudo gem install httparty








