Skip to content

Instantly share code, notes, and snippets.

@dwilkie
Last active July 25, 2017 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dwilkie/09cbe7375feb1a70f68306d4847036ad to your computer and use it in GitHub Desktop.
Save dwilkie/09cbe7375feb1a70f68306d4847036ad to your computer and use it in GitHub Desktop.
somleng_example.rb
#!/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