jngo (owner)

Fork Of

gist: 4277 by schacon gist example api post

Revisions

gist: 130138 Download_button fork
public
Description:
Gist API example.
Public Clone URL: git://gist.github.com/130138.git
Embed All Files: show embed
example_gist_create.rb #
1
2
3
4
5
6
7
8
9
10
11
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
output.xml #
1
2
3
4
5
6
7
8
9
<?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>