Call Us Today! 877.742.2583




Page tree

Versions Compared

Key

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

...

included with FreeSWITCH tree

Example

...

Code Block
#!/usr/bin/php

...

require_once('ESL.php');

if ($argc > 1) {
    array_shift($argv);
    $command = sprintf('%s', implode(' ', $argv));
    printf("Command to run is:

...

 %s\n", $command);
    $sock = new ESLconnection('localhost', '8021', 'ClueCon');
    $res = $sock->api($command);
    printf("%s\n", $res->getBody());
} else {
    printf("ERROR: You Need To Pass A Command\nUsage:\n\t%s <command>", $argv[0]);
}

...

The example above is designed to run from the local console using the default credentials for the event socket and run whatever command is based as an argument.

Example

...

Code Block
$ ./single_command.php status

...

Command to run is: status

UP 0 years, 0 days, 2 hours, 37 minutes, 44 seconds, 733 milliseconds, 519 microseconds
0 session(s) since startup
0 session(s) 0/30
1000 session(s) max

Example of making an inbound connection from script to FS and execute a FSAPI command show channels.

Example

...

Code Block
#!/usr/bin/php

...

require_once('ESL.php');

...

$command = "show channels";
$sock = new ESLconnection('localhost', '8021', 'ClueCon');
$res = $sock->api($command);
printf("%s\n", $res->getBody());

...

Example of making an inbound connection and listening for events and printing them serialized.

...