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.
Enable access
Section titled “Enable access”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.
-
Log in to the switch as
root. -
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 -
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.
Request and response
Section titled “Request and response”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.
callback.php
Section titled “callback.php”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.
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'OK: callback has been initiatedavailable_credit.php
Section titled “available_credit.php”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 |
curl -u simpleapi-user:PASSWORD \ 'https://panel.example.com/simpleapi/available_credit.php?username=00001'12.50000000 USDAn unknown username returns a line starting with ERROR:.