Skip to content

Instantly share code, notes, and snippets.

@ongaeshi
Created November 12, 2016 14:44
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 ongaeshi/e23496b467129f032aeb99fdee0ac08d to your computer and use it in GitHub Desktop.
Save ongaeshi/e23496b467129f032aeb99fdee0ac08d to your computer and use it in GitHub Desktop.
Created by RubyPico at Sat Nov 12 23:44:12 2016
updated file contents
a new file
あいうえお
modified contents
@ongaeshi
Copy link
Author

ongaeshi commented Nov 12, 2016

# https://developer.github.com/v3/gists/#create-a-gist
json = {
  description: "Created by RubyPico at #{Time.now}",
  public: true,
  files: {
    "file1.txt" => {
      content: "updated file contents"
    },
    "old_name.txt" => {
      filename: "new_name.txt",
      content: "modified contents"
    },
    "new_file.txt" => {
      content: "a new file\nあいうえお"
    },
  }
}

puts Browser.post(
  "https://api.github.com/gists",
  header: { "Authorization" => "token XXXXXXXX" },
  json: json
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment