Skip to content

Instantly share code, notes, and snippets.

@judismith
Created August 21, 2012 03:10
Show Gist options
  • Save judismith/3411183 to your computer and use it in GitHub Desktop.
Save judismith/3411183 to your computer and use it in GitHub Desktop.
Ruby script to list of clients from Toggl through API
require 'net/https'
require 'uri'
@path = '/api/v6/clients.json'
# insert API token in the user variable
@user = ''
@pass = 'api_token'
uri = URI.parse('https://www.toggl.com')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
req = Net::HTTP::Get.new(@path)
req.basic_auth @user, @pass
response = http.request(req)
resp = response.body
File.open('toggl_client.txt', 'w') {|f| f.write(resp)}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment