

This is important so I don't break it in a future version unintentionally. Contributing to url_expander ¶ ↑Ĭheck out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yetĬheck out the issue tracker to make sure someone already hasn't requested it and/or contributed itĬommit and push until you are happy with your contribution Thats about it, don't forget to register your class.
Tinyurl expander code#
code = 200 = responseĮlse error = ( JSON. class Request include HTTParty base_uri '' headers 'Content-Type' => 'application/json' headers "Content-length" => "0" end private # A custom fetcher function expand the url using the api. def initialize( short_url, = self super( short_url, options)įetch_url end # Request class will include httpartty and set the base_uri for that service. Subclass UrlExpander::Expanders::Basic ¶ ↑ class Tinyurl 'DRppM' without / PATTERN = %r'( # Reference to the class used by the base class to access Request class within attr_reader :parent_klass # initialize function to do custom initialization # make sure to set the and call super # calling super will only exract the shortening for the url using the pattern defined above.
Tinyurl expander manual#
UrlExpander::Expanders::Scrape: No api, no 301 redirect, manual scraping.Įach service must subclass one of these classes. UrlExpander::Expanders::API: For services that provide expand api. UrlExpander::Expanders::Basic: For services that provides 301 redirect. expand( "")ĭlvr.it UrlExpander :: Client. , sn.im, cl.lk,, UrlExpander :: Client. expand( '', :config_file => '/Users/moski/url_expander_credentials.yml')īit.ly and bitly domains(13,231 domains as of July 19-2011) UrlExpander::Client.expand("")ī UrlExpander :: Client. Default is “~/url_expander_credentials.yml”. You need to provide YAML file with the access credentials. :config_file – Some services Require credentials to access the api (such as bitly). Default value is 10 UrlExpander :: Client. :limit – If the nested_shortening is turned on, then :limit controls the max number of redirection allowed.

expand( "", :nested_shortening => false) => "" Require and Use require 'rubygems' # if ruby true) UrlExpander :: Client.

Tinyurl expander how to#
Install ¶ ↑ gem install url_expander How to use ¶ ↑ĭownload the config used to authenticate with some of the shortening services curl -s -o ~/url_expander_credentials.yml I tried to make it as simple as possible to extend & add new services. Url_expander is a good start, it covers (13,231 bit.ly domains + 28 different services). I've been working on an analytical tool for and i wanted a way to expand all the shortened urls.

) without having to refresh the page.The idea is simple, One expander to expand them all.
