Skip to content

Instantly share code, notes, and snippets.

@sudar
Forked from schacon/example_gist_create.rb
Created January 1, 2010 11:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sudar/267087 to your computer and use it in GitHub Desktop.
Save sudar/267087 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'uri'
# /api/v1/:format/new
# /api/v1/:format/gists/:user
# /api/v1/:format/:gist_id
res = Net::HTTP.post_form(URI.parse('http://gist.github.com/api/v1/xml/new'),
{ 'files[file1.ab]' => 'CONTNETS',
'files[file2.ab]' => 'contents' })
puts res.body
<?xml version="1.0" encoding="UTF-8"?>
<gists type="array">
<gist>
<public type="boolean">true</public>
<description nil="true"></description>
<repo>4278</repo>
<created-at type="datetime">2008-08-06T13:30:32-07:00</created-at>
</gist>
</gists>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment