Created
October 28, 2013 19:05
-
-
Save moos3/7202667 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| chdir(__DIR__); | |
| require_once('./vendor/autoload.php'); | |
| // Put all Freeswitch functions and Settings here | |
| require_once('./settings.inc'); | |
| require_once('./lib/freeswitch_lib.inc'); | |
| $app = new \Slim\Slim(); | |
| $app->view(new \JsonApiView()); | |
| $app->add(new \JsonApiMiddleware()); | |
| // Get FS Status via ESL | |
| $app->get('/status',function() use ($app) { | |
| $output = eslCommand("status"); | |
| $callers = eslParser($output); | |
| $app->render(200,array( | |
| 'msg' => $callers, | |
| )); | |
| }); | |
| // Create Users flat file | |
| $app->post('/create/extension', function() use ($app) { | |
| global $access_key; | |
| $req = $app->request(); | |
| $user = json_decode($req->getBody(),true); | |
| if ($user['access_key'] == $access_key){ | |
| if (createExtension($user)) { | |
| $app->render(200,array('msg'=>'User was created')); | |
| } else { | |
| $app->render(400,array('msg'=> "Failed to create user", 'error'=>true)); | |
| } | |
| } else { | |
| $app->render(400,array('msg'=> 'access denied', 'error'=>true)); | |
| } | |
| }); | |
| $app->run(); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment