Author Topic: Want to do more with php need connection with phpapi  (Read 2812 times)

scdzaak

  • Newbie
  • *
  • Posts: 19
  • Karma: 1
    • View Profile
    • Engineering and solutions
Want to do more with php need connection with phpapi
« on: March 18, 2011, 03:19:43 PM »
Dears,

In askozia their is a directory #etc/asterisk/agi-bin
This is the standard directory for the files phpagi-asmanager.php and phpagi.php

You need these files if you want to communicate with the asterisk system.
I want to monitor the connected phones, and found the very small php app (see listing)
What will be the best place to place the file .. so that I can go with the browser to:
http://[url askozia bpx]/extcheck.php

OR:

Is that NOT possible on the askozia platform ?


   #!/usr/bin/php -q
   <?php
   /*
   * Filename:      extcheck.php
   * Auther:       Zeeshan A Zakaria
   */

   require_once "phpagi-asmanager.php"; // Note that phpagi-asmanager.php in itself includes phpagi.php
   $AGI = new AGI();
   $astman = new AGI_AsteriskManager();
   if (!$astman->connect("127.0.0.1", "sadmin", "sadmin")) {
     exit (1);
   }
   $callee = $AGI->request['agi_extension'];
   $extstatus = is_ext_avail($callee);
   $AGI->verbose("------------------------------------------");
   $AGI->verbose("Status for extension $callee is $extstatus");
   $AGI->verbose("------------------------------------------");
   if ($extstatus>0) {
      $AGI->goto('cancel'); // Note that 'cancle' is the name of a context in our dialplan
   }
   $astman->disconnect();
   exit(0);

   function is_ext_avail($extnum) {
      global $astman;
       $status = $astman->ExtensionState( $extnum, 'my-extensions' ); // my-extensions is a context in our dialplan
       $status = $status['Status'];
    return $status;
    }
   ?>


Regards,

Eric

See more technical info: http://blog.syscodata.nl
Binnenkort meer informatie ook te vinden op http://www.askozia.nl