PHP Classes

File: sample.php

Recommend this page to a friend!
  Classes of Joshua hatfield   floAPI   sample.php   Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: An example script
Class: floAPI
Interface to control Asterisk PABX program
Author: By
Last change:
Date: 17 years ago
Size: 1,859 bytes


Class file image Download
 * Original floAPI copyright (C) 2005 by Joshua Hatfield. *
 * *
 * In order to use any part of this floAPI Class, you must comply with *
 * the license in 'license.doc'. In particular, you may not remove this *
 * copyright notice. *
 * *
 * Much time and thought has gone into this software and you are *
 * benefitting. We hope that you share your changes too. What goes *
 * around, comes around. *

// Include the file.

// Create the object.
$sampleapi = new floAPI("username", "password", "");

// Start collecting events.

// Run a test command (sip show peers).
echo($sampleapi->request("COMMAND", array("COMMAND" => "sip show peers")));

// Wait up to twenty seconds for an event to happen, checking
// once each second.
$t = 0;
$events_found = $sampleapi->events_check()) && $t < 20){

// How many did we find in one check?
echo("-- Events found: $events_found\r\n\r\n");

// Display collected events.
while($event = $sampleapi->events_shift()) {

// Close the connection.

"LOGGED OUT!\r\n\r\n");

"-- Additional events: ".$sampleapi->events_check());

// Display any events since the first check till logout.
while($event = $sampleapi->events_shift()) {