Skip to content

Instantly share code, notes, and snippets.

@v6ak
Created October 21, 2013 17:53
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 v6ak/7088062 to your computer and use it in GitHub Desktop.
Save v6ak/7088062 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# encoding: UTF-8
require 'net/http'
require 'net/https'
require 'uri'
## config ##
callers = {
"v-sip" => "910xxxxxx", # zpětné volání na SIP (hodí se s dobrým připojením na internet)
"v-phone" => "77xxxxxxx", # zpětné volání na telefon
"v-o2" => "60xxxxxxx", # zpětné volání na druhý telefon
"v-second" => ARGV[1] # zpětné volání na číslo zadané jakko druhý parametr
}
username='SIPové uživatelské jméno'
password='SIPové heslo'
ca_file = "/usr/share/linphone/rootca.pem"
#ca_file = File.join(File.dirname(__FILE__), "www.odorik.cz")
## script ##
# Skript vychází z http://www.odorik.cz/w/api:ukazky
caller = callers[File.basename($0)]
authentication = { 'user' => username, 'password' => password }
callback = { 'caller' => caller, 'recipient' => ARGV[0] }
uri = URI.parse('https://www.odorik.cz/api/v1/callback')
request = Net::HTTP::Post.new(uri.path)
request.form_data = authentication.merge(callback)
http = Net::HTTP.new(uri.host, uri.port)
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.use_ssl = true
http.ca_file = ca_file
response = http.start {|http| http.request(request)}
unless response.body.include? 'callback_ordered'
puts "zpětné volání nešlo objednat. Důvod: #{response.body}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment