...
Unified API can be tested using the Sandbox numbers. The example below uses the Create Simple PhoneCalls request to make the call.
Code Block | ||
---|---|---|
| ||
require "net/http" require "json" # Modify these values with the ones you intend to use VN_SERVER_ADDRESS = "CHANGEME" API_ACCESS_TOKEN = "CHANGEME" EXTENSION_NUMBER = "CHANGEME" SANDBOX_NUMBER = "CHANGEME" # URI that identifies the phone call uri = URI("https://"+VN_SERVER_ADDRESS+"/uapi/phoneCalls/@me/simple") # The parameters sent in the body of the request data = {"extension" => EXTENSION_NUMBER, "phoneCallView" => [{ "source" => EXTENSION_NUMBER, "destination" => SANDBOX_NUMBER }] } # Initializes the request by setting the HTTP headers, query and body parameters and the URI path req = Net::HTTP::Post.new(uri.path) req.body = JSON.dump(data) req['Authorization'] = 'Bearer ' + API_ACCESS_TOKEN req['Content-type'] = 'application/json' # Makes a HTTP POST request using SSL res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') do |http| http.request(req) end # Parses the JSON response objectResult = JSON.parse(res.body) puts JSON.pretty_generate(objectResult) |
Park a Phone Call Call
Anchor | ||||
---|---|---|---|---|
|
The example below demonstrates how you can use Unified API to park a party of an ongoing phone call. It uses the the Park PhoneCalls request.
Code Block | ||
---|---|---|
| ||
require "net/http" require "json" # Modify these values with the ones you intend to use VN_SERVER_ADDRESS = "CHANGEME" API_ACCESS_TOKEN = "CHANGEME" PHONECALL_ID = "CHANGEME" PHONECALLVIEW_ID = "CHANGEME" EXTENSION_NUMBER = "CHANGEME" # URI that identifies the phone call uri = URI("https://"+VN_SERVER_ADDRESS+"/uapi/phoneCalls/@me/"+ EXTENSION_NUMBER +"/"+PHONECALL_ID) # The parameters sent in the body of the request data = { "action" => "Park", "phoneCallViewId" => PHONECALLVIEW_ID } # Initializes the request by setting the HTTP headers, query and body parameters and the URI path req = Net::HTTP::Put.new(uri.path) req.body = JSON.dump(data) req['Authorization'] = 'Bearer ' + API_ACCESS_TOKEN req['Content-type'] = 'application/json' # Makes a HTTP PUT request using SSL res = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') do |http| http.request(req) end # Parses the JSON response objectResult = JSON.parse(res.body) puts JSON.pretty_generate(objectResult) |
...
The example below demonstrates how you can use Unified API to transfer a call to a public number, not registered with VoipNow. It uses the the Transfer PhoneCalls request.
...
The example below demonstrates how you can use Unified API to record an ongoing conversation. This action is possible for phone numbers that are registered with VoipNow. The recording is saved in the the wav format and uses the StartRecording PhoneCalls request.
...
Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution 4.0 International.