Loading the gem:
require 'ruby-bitly'
Set global configuration:
Bitly.config do |c|
c.login = 'login-here'
c.api_key = 'api-key-here'
c.use_ssl = false # read more below
c.proxy = 'http://localhost:8888' # read more below
end
Or set them individualy:
Bitly.login = 'login-here'
Bitly.api_key = 'api-key-here'
Bitly.use_ssl = false # read more below
Bitly.proxy = 'http://localhost:8888' # read more below
Or set them on methods if you prefer (see it below).
All calls will use the proxy specified by environment variable "http_proxy" by default.
You can set the proxy directly if you prefer:
Bitly.proxy = 'http://localhost:8888'
Usage: bitly [options] URL
-l, --login LOGIN You need a free Bitly login and api key. Sign up here: http://bit.ly/a/sign_up.
-k, --api-key KEY You can find your api key here: http://bit.ly/a/your_api_key.
-d, --domain DOMAIN The short domain to use: either bit.ly, j.mp, bitly.com or a custom short domain.
This option will override the default short domain selected in your Bitly account settings.
-s, --shorten Given a long URL, returns a Bitlink.
-e, --expand Given a Bitlink, hash or custom path, returns the target (long) URL.
-u, --user-clicks The total count of clicks to this user's Bitlink.
-g, --global-clicks The total count of the corresponding Bitly aggregate hash.
-h, --help Print this help.
-v, --version Print version.
Basic examples for command line:
bitly -s http://dx7.github.io
bitly -e http://bit.ly/2dAjjfo
bitly --user-clicks http://bit.ly/2dAjjfo
bitly --global-clicks http://bit.ly/2dAjjfo
bit.ly API requires authentication credentials. You can get it on bit.ly[https://app.bitly.com/Ba48fIHfOg5/bitlinks/2Q1GQcD?actions=accountMain&actions=settings&actions=advancedSettings&actions=apiSupport].
Using commmand line you can supply credentials as parameters. For example:
bitly -l <login-here> -k <api-key-here> -s http://dx7.github.io
Or you can create the file ~/.bitly with that content:
login: <login-here>
api_key: <api-key-here>
Copyright (c) 2010 dx7. Licensed under the MIT License:
http://www.opensource.org/licenses/mit-license.php
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].