LinkShare API
Ruby wrapper for LinkShare Publisher Web Services. Supported web services:
If you need services that are not yet supported, feel free to contribute. For questions or bugs please create an issue.
Installation
Add this line to your application's Gemfile:
gem 'linkshare_api'
And then execute:
$ bundle
Or install it yourself as:
$ gem install linkshare_api
Requirements
Ruby 1.9 or above.
Usage
Before using LinkShare API you need to set up your publisher token first. If you use Ruby on Rails, the token can be set in a configuration file (i.e. app/config/initializers/linkshare_api.rb), otherwise just set it in your script. The token can be found on LinkShare's Web Services page under the Links tab.
require "linkshare_api" # no need for RoR
LinkshareAPI.token = ENV["LINKSHARE_TOKEN"]
Automated Link Generator
Generate affiliate URLs using Automated LinkGenerator service.
Below is an example of generating an affiliate URL for Walmart. Walmart merchant code is 2149.
url = "http://www.walmart.com/cp/Electronics/3944?povid=P1171-C1093.2766-L33"
affiliate_url = LinkshareAPI.link_generator(2149, url)
Extra Configuration
LinkshareAPI.api_timeout- the timeout set when initiating requests to LinkShare Web Services (default value is 30 seconds)
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request
