Class: Shortie::Shorteners::Tinycc

Inherits:
BaseShortener show all
Defined in:
lib/shortie/shorteners/tinycc.rb

Instance Attribute Summary

Attributes inherited from BaseShortener

#url

Instance Method Summary collapse

Methods inherited from BaseShortener

#initialize, shorten

Constructor Details

This class inherits a constructor from Shortie::BaseShortener

Instance Method Details

#shortenObject



4
5
6
7
8
9
10
11
12
# File 'lib/shortie/shorteners/tinycc.rb', line 4

def shorten
  xml = SimpleHttp.get("http://tiny.cc/?c=rest_api&m=shorten&version=2.0.1&format=xml&longUrl=#{escaped_url}&login=lassebunk&apiKey=7ec76292-2999-48ab-ad8a-91798282ad59")
  doc = REXML::Document.new(xml)

  error_msg = doc.elements["restapi/errorMessage"]
  raise error_msg.text unless error_msg.text.nil?

  doc.elements["restapi/results/*/shorturl"].text
end