Created
April 27, 2011 01:45
-
-
Save infynyxx/943581 to your computer and use it in GitHub Desktop.
Sailthru gem usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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