Sha256: ac9a8a03f51730e36c49ab6ae86b5eadb6a44bffbee9f85eeba6d6fab539facf
Contents?: true
Size: 1.96 KB
Versions: 5
Compression:
Stored size: 1.96 KB
Contents
#!/usr/bin/env ruby local_libs = [ File.join(File.dirname(__FILE__), *%w[../lib/clickatell]), File.join(File.dirname(__FILE__), *%w[../lib/clickatell/utility]) ] if File.exist?(local_libs.first) local_libs.each { |lib| require lib } else require 'rubygems' require 'clickatell' require 'clickatell/utility' end # parse command line options options = Clickatell::Utility::Options.parse(ARGV) # authenticate and load the API api = Clickatell::API.authenticate(options.api_key, options.username, options.password) begin if options.show_balance puts "Retrieving account balance..." puts "You have #{api.account_balance} credits remaining." exit 0 elsif options.show_status puts "Getting status of message ##{options.message_id}." status = api.message_status(options.message_id) puts "Status: #{Clickatell::API::MessageStatus[status]} (##{status})." exit 0 else puts "Sending '#{options.message}' to #{[options.recipient].flatten.join(", ")}..." additional_opts = {} additional_opts[:from] = options.from if options.from msg_id = api.send_message(options.recipient, options.message, additional_opts) puts "Message sent successfully (message id: #{[msg_id].flatten.join(", ")})." exit 0 end rescue Clickatell::API::Error => e case e.code when '001', '002', '003', '005', '108' puts "Authentication failed. Please check your username, password and API key and try again." exit 1 when '004' puts "Your account has been frozen. Please contact Clickatell support." exit 1 when '007' puts "Requests for this API key are not permitted from this IP address." exit 1 else puts "Unexpected error occurred. #{e.message} (error code: #{e.code})." puts "Please contact the author (contact@lukeredpath.co.uk) with the above error." exit 1 end rescue Timeout::Error puts "The connection the the Clickatell service timed out" puts "Please check your network settings and try again." exit 1 end
Version data entries
5 entries across 5 versions & 3 rubygems
Version | Path |
---|---|
clickatell-0.8.0 | bin/sms |
clickatell-ruby19-0.7.1 | bin/sms |
clickatell-0.7.1 | bin/sms |
dimiro1-clickatell-0.7.0 | bin/sms |
clickatell-0.7.0 | bin/sms |