Skip to content

Instantly share code, notes, and snippets.

@tmarkiewicz
Created January 2, 2011 22:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save tmarkiewicz/762889 to your computer and use it in GitHub Desktop.
Save tmarkiewicz/762889 to your computer and use it in GitHub Desktop.
Example Ruby code for the StatsMix API.
# Full documentation for the StatsMix API can be found here: http://www.statsmix.com/developers
# In this example, a stat is posted using Ruby's net/http library.
require 'rubygems'
require 'net/http'
require 'uri'
require 'json'
url = URI.parse("http://api.statsmix.com/api/v1/stats")
http = Net::HTTP.new(url.host, url.port)
meta = {'Food' => 'Ice Cream', 'Calories' => 500}
request = Net::HTTP::Post.new(url.path)
request.add_field("X-StatsMix-Token", "API_KEY")
request.set_form_data({
"value" => "VALUE",
"profile_id" => "PROFILE_ID",
"metric_id" => "METRIC_ID",
"generated_at" => "DATE",
"meta" => meta.to_json
})
response = http.request(request)
puts response.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment