bgUrl api - ruby simple example

bgurl.org

def get_bg_url(long_url)
  url = URI.parse("http://bgurl.org/api/links")
  req = Net::HTTP::Post.new(url.path)
  req.set_form_data({'website_url' => long_url})
  http = Net::HTTP.new(url.host, url.port)
  response = http.start {|http| http.request(req) }
  doc = Hpricot::XML(response.body)
  (doc/:link/:permalink).first.innerHTML
end

bgURL api - примерни - request и response

bgurl.org

request.xml
POST http://bgurl.org/api/links

 
<link>
  <website_url>http://www.sharesnippets.com</website_url>
</link>

response.xml
<?xml version="1.0" encoding="UTF-8"?>
<link>
  <website_url>http://www.sharesnippets.com</website_url>
  <permalink>http://bgurl.org/0eWb</permalink>
</link>