Skip to content

aortbals/bitly_exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bitly Exporter

Code Climate Build Status Coverage Status

This gem exports a user's links from the Bitly V3 API. It requires a generic OAuth access token that you can obtain from Bitly. It makes use of the User Link History API.

Installation

Add this line to your applications Gemfile:

gem 'bitly_exporter'

Or install it directly:

gem install bitly_exporter

Usage

First, create a user and an exporter:

user = BitlyExporter::User.new('youroauthaccesstoken')
exporter = BitlyExporter::Exporter.new(user)

The export method triggers the export. There are two ways to consume the results.

Using a block:

exporter.export do |link|
  # Create a record, store the link, etc
end

As a traditional method:

results = exporter.export

results.each_with_index do |link, index|
  puts "Link Index: #{index}, Link: #{link.link}"
end

export takes two optional arguments: progress & max. Set progress to true to see progress while exporting. Setting max will import (in increments of 100) up to the maximum specified. This is a good way to see a sample response.

Show progress:

results = exporter.export(true)

With max:

exporter.export(false, 200) do |link|
  # Create a record, store the link, etc
end

Link Objects

See the API docs for more information. A link object has the following methods:

  • link (short_link)
  • long_url
  • aggregate_link (global_bitly_identifier)
  • archived
  • title
  • private
  • client_id
  • created_at
  • modified_at
  • user_ts

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Write Tests
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

License

This code is provided under the MIT license. See LICENSE for more details.

About

Export your link history from Bitly

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages