Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Updated using 4PSA automated script

Excerpt

This example written in PHP allows users to manage VoipNow accounts and fetch call statistics. Download.

Table of Contents
maxLevel3

 

Note

This demonstrative code SHOULD NOT be used in production. It is designed to show how a client application interacts with the VoipNow SystemAPI. From this perspective, validations and error-checks aiming to demonstrate the most common mistakes are minimal and can be done easily.

This example applies for access token at administrator level.

 

How To Install It

System Requirements

In order to be able to use the SystemAPI PHP Tool, your system must be compliant with the requirements below:

  • Your system needs to have PHP 5.1.2 or any subsequent version installed.
  • PHP must be compiled using the the --enable-soap configuration configuration option.
  • The SystemAPI PHP Tool requires the PHP extension extension libxml  - Version 2.5.4 or any subsequent version.

...

STEP 1: Start by downloading the the archive.  

STEP 2: Extract the files and copy them to a directory that can be accessed over the Web.

STEP 3: In order to use the tool, you must configure it. To do so, please open the config.php file php file located  in in the <PATH_TO_SYSTEMAPI_PHP_TOOL>/config directory, and set the variables as explained below.

STEP 4: Set the the $voipnow_ip variable variable to the IP or hostname of your VoipNow server.

...

Every SOAP request needs to contain the credentials in order to authenticate a user to the SystemAPI.

Set the the $voipnow_access_token in the configuration file to the oauth token of the account you want to use.

Note
Although everybody can see the web interface of the SystemAPI PHP Tool, it is important that the user account associated with the parameter $voipnow_access_token is allowed to access the SystemAPI web service. For more information on how to generate an access token for your application, please check check Access Management document document.

Examples

To access the interface, simply visit https://<IP>/<PATH_TO_SYSTEMAPI_TOOL>/index.php.

...

Problem

Solution

Current PHP version > 5.1.2 setup is not validated
You should check your PHP installation.
PHP is configured with --enable-soap setup is not validatedYou should make sure the PHP is compiled using the the --enable-soap option option.
VoipNow SystemAPI is reachable setup is not validated

You should check the configuration file and make sure you have correctly set the server or connection parameters.

...

  • Adding accounts - allows you to add service providers, organizations, users and extensions;
  • Call costs costs - allows you to fetch statistics for certain accounts.

...

Parameter

Required

Description

Company

No

The company name of the user

Contact name

Yes

The contact name of the user

Login

Yes

Username for the new account

Password

Yes

Password for the new account

Phone

No

Phone number of the new account

Fax

No

Fax number of the new account

Email

No

Email of the new account

Address

No

Address of the new account

City

No

City for the new account

Postal/ZIP code

No

Postal/ZIP code for the new account

Country

Yes

Select a country from the list of countries

Region

Yes

Select a region from the list

Timezone

Yes

Timezone that will be used by the new account

Interface language

Yes

User interface language

Phone language

Yes

The language of the user phone

Notes

No

More notes about the account

Set the the $account_type in the configuration file to the account type you want to add:

  • If you want to add a Service Provider account, you can set the variable variable $account_type = "service provider", or simply select this account type in the form.
  • If you want to add an Organization account, you must set the the $serviceprovider_id id to the ID of the service provider that owns the new organization.  You You can set the variable variable $account_type = "organization", or simply select this account type in the form. 
  • If you want to add a User a User account,  you must set you must set the $organization_id id to the ID of the organization that owns the new user.You can set the variable variable $account_type = "user", or simply select this account type in the form.
  • If you want to add an Extension account, you must set the the $user_id id to the ID of the user that owns the new extension.   You can set the variable variable $account_type = "extension", or simply select this account type in the form.

To create a user by means of a template, you must set the configuration variable variable $template_id to to a valid VoipNow template ID. The SystemAPI web service allows you to get the list of all the templates in the system by calling GetTemplates, an operation available under the PBX component. For more details on how to use this operation, please read read SystemAPI documentation documentation.

To create a user by means of a charging plan, you must set the configuration variable variable $billing_plan_id to to a valid VoipNow charging plan ID. The SystemAPI web service allows you to get the list of all the charging plans in the system by calling GetTemplates, an operation available under the PBX component. For more details on how to use this operation, please read read SystemAPI documentation documentation.

Call Costs

By using this section of the application, you can fetch call stats for a specific user, month, and year from the VoipNow system. You can set the information using the form, as explained below:

...

Except where otherwise noted, content in this space is licensed under a Creative Commons Attribution 4.0 International.