/bitly-shortener

Shorten URLs with Bitly

Primary LanguageRubyMIT LicenseMIT

bitly-shortener

gem install bitly-shortener

OR in Gemfile:

gem 'bitly-shortener'

Getting Started

  1. Generate your https://bit.ly access token from here
  2. Set the token obtained in 1 above as your BITLY_API_KEY

Usage

You can use this within your app or via the CLI.

Code:

url = Bitly::Shortener::Request.new('https://www.wsj.com/articles/covid-upended-americans-finances-just-not-in-the-ways-we-expected-11609081200')
shortened_url = Bitly::Shortener::Shorten.new(url).shortened_url

pp shortened_url # => https://on.wsj.com/2MiuBuo

CLI:

$ bin/shorten -l https://www.wsj.com/articles/covid-upended-americans-finances-just-not-in-the-ways-we-expected-11609081200

https://on.wsj.com/2MiuBuo/app

$