Class: Shortie::Shorteners::Tinycc
- Inherits:
-
BaseShortener
- Object
- BaseShortener
- Shortie::Shorteners::Tinycc
- Defined in:
- lib/shortie/shorteners/tinycc.rb
Instance Attribute Summary
Attributes inherited from BaseShortener
Instance Method Summary collapse
Methods inherited from BaseShortener
Constructor Details
This class inherits a constructor from Shortie::BaseShortener
Instance Method Details
#shorten ⇒ Object
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 |