Last active
July 25, 2017 08:12
-
-
Save dwilkie/09cbe7375feb1a70f68306d4847036ad to your computer and use it in GitHub Desktop.
somleng_example.rb
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
#!/usr/bin/env ruby | |
RESULTS_FILE = "test_mt_results.json" | |
ACCOUNT_SID = "REPLACE_ME" | |
AUTH_TOKEN = "REPLACE ME" | |
CALLER_ID = "345" | |
require 'httparty' | |
results = {} | |
# Add numbers here or load from file (e.g. CSV File) | |
test_numbers = [ | |
"+252634000613" | |
] | |
auth = { | |
:username => ACCOUNT_SID, | |
:password => AUTH_TOKEN | |
} | |
test_numbers.each do |test_number| | |
result = HTTParty.post( | |
"https://somleng.unicef.io/api/2010-04-01/Accounts/#{ACCOUNT_SID}/Calls.json", | |
:body => { | |
"Method" => "GET", | |
"Url" => "http://demo.twilio.com/docs/voice.xml", | |
"To" => test_number, | |
"From" => CALLER_ID | |
}, | |
:basic_auth => auth | |
) | |
json_result = JSON.parse(result.body) | |
call_sid = json_result["sid"] | |
results[call_sid] = { | |
:to => test_number | |
} | |
end | |
File.open(RESULTS_FILE, 'w') { |file| file.write(results.to_json) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment