Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Excerpt

This example written in C++ allows developers to manage VoipNow manage VoipNow accounts and view information about calls. Download.

Table of Contents
maxLevel3

...

How To Install It

System Requirements for Linux

In order to be able to use the SystemAPI C++ example, you must have on your Linux system:

Setup

STEP 1: Please download the example archive and extract the files to a location of your choice.Command example for extracting the archive to a folderfiles from our GitHub repository:

Code Block
mkdir <PATH_TO_DEMO_FOLDER>
unzip CPPSOAPDemo.zip -d <PATH_TO_DEMO_FOLDER>
Note

The folder names and locations are not important.

You should replace the locations in the example commands with the locations of your choice.

git clone https://github.com/4psa/systemapi-example-c.git

 

You In the folder in which you extracted the example archive you should now find the following files in the systemapi-example-c folder:

File

Description

README.txtRead me file that provides instructions on how to develop, compile and run SystemAPI applications.
createDemoFiles.shScript that automatically generates the stub files and compiles the demo applications.
Demo/DemoAddServiceProvider.cppDemo application that adds a new service provider.
Demo/DemoAddOrganization.cppDemo application that adds a new organization to a service provider.
Demo/DemoAddUser.cppDemo application that adds a new user to an organization.
Demo/DemoAddExtension.cppDemo application that adds a new extension to an organization.
Demo/DemoCallCosts.cppDemo application that makes a call report.

Demo/RandomChargingPlan.cpp
Demo/RandomChargingPlan.h

Utility class that generates a random charging plan ID.

Demo/utils.cpp
Demo/utils.h

Miscellaneous utilitary functions.
Demo/MakefileMakefile that compiles and generates executables for the demo applications.

...

Code Block
./createDemoFiles.sh <server_IP>hostname> <PATH_TO_GSOAP> <PATH_TO_SCHEMA_FILES>

...

Parameter

Description

<server_IP>hostname>The server's IPhostname.
<PATH_TO_GSOAP>Complete path to the folder where you extracted your gsoap.
<PATH_TO_SCHEMA_FILES>Complete path to the folder where you have the schema files.

...

STEP 7: After you have installed all the prerequisite tools and you have your schema files, you need to compile the voipnowservice.wsdl file from your schema folder. It is recommended that you use wsdl2h, that is the application provided by gSOAP. You can find it in your gsoap directory, i.e. /<PATH_TO_GSOAP>/bin.

Navigate to to /<PATH_TO_GSOAP>/bin and run the followin command to compile the WSDL:

...

To make things easy, we copied all the 4PSA VoipNow schemes 4PSA VoipNow schemes to /<PATH_TO_GSOAP>/bin. Otherwise, you must specify the full path to voipnowservice.wsdl.

...

Tip

You can now use the recently created classes to write applications that interact with your VoipNow your VoipNow server.

You will notice that after running the applications, there are three files in your application folder: TEST.LOG, SENT.LOG, and RECV.LOG; they contain useful logs about your application:

...

Note

Although everybody can use the SystemAPI C++ example, it is important that the user account used to connect to the VoipNow the VoipNow server is allowed to access the SystemAPI web service. For more information, please read the Access Management section.

...

This type of authentication requires that you provide a valid access token that is generated through generated through an OAuth flow using the key and secret of your application. The code should look like this:

...

For more information on how to generate an access token for your application, please check Access Management document.

Examples

The The SystemAPI C++ Tool contains demo applications that simulate the following operations:

  • add a Service Provider Account,  
  • add an Organization Account,  
  • add a User Account,  
  • add an Extension Account,
  • get the Call Costs for a User Account.

...

Adding Other Account Types

Tip

These examples can be found in the package downloaded with the SystemAPI Cexamples can be found in the package downloaded with the SystemAPI C++  ToolTool.

If you wish to add other account types (organizations, extensions or users), there is not much to change from the program listed above. First of all, you will need to create the proper object, so instead of writing:

...

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