Excerpt |
---|
This page describes an App that uses UnifiedAPI to place phone calls and returns the status of the call to the user. Download. |
Table of Contents | ||
---|---|---|
|
Note | ||
---|---|---|
| ||
Download here. Do not hesitate to contribute in order to make this example better - we welcome Pull Requests!This demonstrative code SHOULD NOT be used in production. It is designed to simply show how an App interacts with UnifiedAPI. From this perspective, validations and error-checks aiming to demonstrate the most common mistakes are minimal and can be done easily. |
Overview
CallMeButton is an App written in PHP that enables users to place calls. It uses the PhoneCall resource exposed by Unified API and the following requests:
- Create PhoneCall - Creates phone calls using any given source and destination
- List PhoneCall - Fetches the list of in progress phone calls in the system at a point of time
It is an excellent starting point for any PHP developer.
Installation
In order to be able to use the CallMeButton App, you need a webserver web server with PHP 5.3 or higher installed.
STEP 1: Download the files.Download the archive, extract the files, and copy them to a Switch to the directory that can be accessed over the Web.web (e.g /var/www/html) and clone the Git repository:
Shell |
---|
git clone https://github.com/4psa/app-callmebutton.git |
...
For example, if httpd
is the name of the user and the name of the group to which the webserver belongs to:
...
Shell |
---|
chmod -R 755 <PATH_TO_CallMeButton> |
...
chown -R httpd:httpd <PATH_TO_CallMeButton> |
...
In order to use the App, you must configure it by opening the file <PATH_TO_CallMeButton>/interface/config/config.php
and changing the following settings:
Name | Description |
---|---|
VN_SERVER_IP | The IP or hostname of your VoipNow server; |
VN_EXTENSION | The extended number of a phone terminal extension. This extension will be charged for the phone call. |
OAUTH_APP_ID | OAuth App ID or key. A 32 char-long string used by the App to identify itself with the system. Visit this page to see how the OAuth APP ID can be obtained. |
OAUTH_APP_SECRET | OAuth App Secret. A 32 char-long secret used by the system to establish ownership of the App ID or key. Based on this pair, the system will recognize the new App and will allow it to generate an access token. Visit this page to see how the Secret can be obtained. |
Note |
---|
Please note that the newly created app will not work properly unless you check the App is trusted option in the Add App form. |
...
As soon as the setup process is complete, the user may access the interface at https://<hostname>//PATH_TO_callmebutton/index.php
. The following form is displayed where the user can enter his/hers phone number:
...
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.
...
The code that makes the request can be found in <Path_To_CallMeButton>/interface/plib/lib.php and is described below:
...
Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution 4.0 International.