Skip to content

Instantly share code, notes, and snippets.

@kazoo04
Created October 9, 2014 10:35
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 kazoo04/0a10546235b7bf196a56 to your computer and use it in GitHub Desktop.
Save kazoo04/0a10546235b7bf196a56 to your computer and use it in GitHub Desktop.
Mesiterror API sample
#encoding: utf-8
require 'uri'
require 'net/http'
require 'json'
uri = 'http://food.kazoo04.com:8080/api/v0/upload'
img_url = 'http://www.example.com/image.jpg'
parsed = URI.parse(uri)
query = URI.escape("url=#{img_url}")
http = Net::HTTP.new(parsed.host, parsed.port)
result = http.post(parsed.path, query).body
json = JSON.parse(result)
puts "result:"
p json[0]
puts "url : #{json[0]['url']}"
puts "label: #{json[0]['label']}"
puts "error: #{json[0]['error']}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment