Перейти до вмісту

Simple API

Цей контент ще не доступний вашою мовою.

The Simple API is a pair of PHP scripts on the panel’s web server that wrap XML-RPC methods behind a plain HTTP request. Use it from devices and scripts that cannot speak XML-RPC or digest authentication. The scripts call the XML-RPC API in trusted mode and answer with one line of plain text.

The scripts are under /simpleapi/ and protected with HTTP basic authentication. The password file is empty after installation, so nobody can call them until you add a user.

  1. Log in to the switch as root.

  2. Add a user to the password file of the environment, and enter the password twice when asked:

    Terminal window
    htpasswd /home/ssp/flysip/fly_web/simpleapi/.htpassword simpleapi-user
  3. Call a script with that user to check the access.

Environment 1 uses .htpassword; environment N uses .htpasswordN in the same directory, for example .htpassword2. The AuthUserFile line of the simpleapi section in the environment’s generated httpd.conf shows the exact file.

Send the parameters as a query string with GET, or form-encoded with POST. A script answers HTTP 200 with one line of text:

  • on success, the result described for the script;
  • on error, ERROR: followed by a space and the fault message of the XML-RPC method.

The scripts wait up to 20 seconds for the switch.

Starts a two-way callback: the switch first calls cld_first, then connects it to cld_second. The script calls make2WayCallback and takes its parameters.

Name Type Required Description
authname string yes VoIP Login of the account that initiates and pays for the callback
cld_first string yes Number called first
cli_first string no Caller number shown on the first leg
cld_second string yes Number connected to the first leg
cli_second string no Caller number shown on the second leg
credit_time int no Maximum length of the first leg in seconds

On success the script returns OK: callback has been initiated.

request
curl -u simpleapi-user:PASSWORD \
'https://panel.example.com/simpleapi/callback.php?authname=account1&cld_first=15555550101&cli_first=15555550199&cld_second=442071234567&cli_second=15555550101&credit_time=300'
response
OK: callback has been initiated

Returns the credit an account can still spend: its credit limit minus its balance, with eight decimals and the account’s currency.

Name Type Required Description
username string yes Account Name of the account
request
curl -u simpleapi-user:PASSWORD \
'https://panel.example.com/simpleapi/available_credit.php?username=00001'
response
12.50000000 USD

An unknown username returns a line starting with ERROR:.