REST Web Service Interface
The Amernet REST API allows you to query meta-data about your account, phone numbers, calls, text messages, and recordings. You can also do some fancy things like initiate outbound calls and send text messages.
Since the API is based on REST principles, it’s very easy to write and test applications. You can use your browser to access URLs, and you can use pretty much any HTTP client in any programming language to interact with the API.
Base URL
All URLs referenced in the documentation have the following base:
https:
//uc.amer.net/uapi/
The Amernet REST API is served over HTTPS. To ensure data privacy, unencrypted HTTP is not supported.
Demo Apps
This area describes the UnifiedAPI demo Apps providing examples for each app:
- CallMeButton — This page describes an App that uses UnifiedAPI to place phone calls and returns the status of the call to the user.
- Click2Conference — This page describes an App that uses UnifiedAPI to invite a group of users to a conference call.
- Click2Fax — This page describes an App that uses UnifiedAPI to send faxes.
- FacebookCallMe — This page describes FacebookCallMe, a small App that allows anyone to place a call through a Facebook App.
Place a Phone Call
To place the phone call, the App uses the Unified API Create Simple PhoneCalls request. It uses the extension defined in the global variable VN_EXTENSION as the source of the call as in the example below. All fields are fictitious.
POST /uapi/phoneCalls/ @me /simple HTTP/ 1.1 HOST x.x.x.x Content Type: application/json Authorization: <OAUTH_ACCESS_TOKEN> { "extension" : "<VN_EXTENSION>" , "phoneCallView" :[ { "source" :[ "<VN_EXTENSION>" ], "destination" :[ "8887777" ] "callerId" : "CallMeButton <8887777>" } ] } |
The code that makes the request can be found in <Path_To_CallMeButton>/interface/plib/lib.php and is described below:
// Fetch token $token = getToken(); $headers = array ( 'Content-type' => 'application/json' , 'Authorization' => $token ); // Initialize the cURL request $request = new cURLRequest(); $request ->setMethod(cURLRequest::METHOD_POST); $request ->setHeaders( $headers ); $jsonRequest = array ( 'extension' => $config [ 'VN_EXTENSION' ], // Number of the extension configured to run with CallMeButton 'phoneCallView' => array ( array ( 'source' => array ( $config [ 'VN_EXTENSION' ]), // Number of the extension configured to run with CallMeButton 'destination' => $phoneNumber // The phone number entered in the form field. ) ); $request ->setBody(json_encode( $jsonRequest )); // Receive the response in JSON format $response = $request ->sendRequest( $reqUrl ); |
The source and extension request parameters can be different as described in the Create Simple PhoneCalls recommendations. The CallMeButton App uses the same extension for both parameters.