Skip to content

Instantly share code, notes, and snippets.

@infynyxx
Created April 27, 2011 01:45
Show Gist options
  • Save infynyxx/943581 to your computer and use it in GitHub Desktop.
Save infynyxx/943581 to your computer and use it in GitHub Desktop.
Sailthru gem usage
require 'rubygems'
require 'date'
require 'json'
require 'sailthru'
api_key = "api_key"
api_secret = 'secret'
api_url = "https://api.sailthru.coma"
sailthru = Sailthru::SailthruClient.new(api_key, api_secret, api_url)
begin
template_name = 'my-template'
email = '[email protected]'
vars = {'name' => 'Prajwal Tuladhar', "myvar" => [1111,2,3]}
options = {'test' => 1}
schedule_time = '+3 hours'
response = sailthru.send(template_name, email, vars, options, schedule_time)
if response['error'] == nil
# everything is OK
# do something
else
# error response from server or invalid JSON format
end
rescue Sailthru::SailthruClientException => e
# catch exception here
print e
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment