├── .gitignore ├── CHANGELOG ├── CHANGELOG.MD ├── LICENSE ├── README.md ├── composer.json ├── contrib └── init.d │ ├── TODO │ └── stasis-centos.php ├── examples ├── ApplicationList.php ├── BasicStasisApplication.php ├── BridgesList.php ├── ChannelDelete.php ├── ChannelOriginate.php ├── ChannelsList.php ├── DeviceStatesList.php ├── EndPointList.php ├── EventGenerateExample.php ├── EventsForApp.php ├── EventsForAppStasis.php ├── MailBoxCreate.php ├── MailBoxesList.php ├── RecordingList.php ├── SoundsList.php └── StasisAppDial.php ├── phpari.ini.sample ├── phpari.php ├── phpari_config.php └── src ├── helpers ├── config_helper.php └── parsing_helper.php └── interfaces ├── applications.php ├── asterisk.php ├── bridges.php ├── channels.php ├── devicestates.php ├── endpoints.php ├── events.php ├── mailboxes.php ├── playbacks.php ├── recordings.php └── sounds.php /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | .idea/ 3 | composer.lock 4 | phpari.ini 5 | examples.dev 6 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | commit 50086e82a65242e48b75a68490a1e0460f7818e5 2 | Author: Nir Simionovich 3 | Date: Thu Feb 5 16:20:01 2015 +0200 4 | 5 | PHPARI based app_dial replacement wireframe - just an example 6 | 7 | commit 891d073374fc7abad9c27033d0c1ed917a179ec1 8 | Author: Nir Simionovich 9 | Date: Thu Feb 5 16:16:26 2015 +0200 10 | 11 | https://github.com/greenfieldtech-nirs/phpari/issues/34 - Fixed 12 | 13 | commit 016b899763da3226f1d47c459509c1463b7e0f5b 14 | Author: Nir Simionovich 15 | Date: Thu Feb 5 15:28:21 2015 +0200 16 | 17 | Commit fixes for the channels and other interfaces - camel casing is now properly used 18 | 19 | commit dba90c17c556e58e6418addea4c4453aa91a2055 20 | Author: Nir Simionovich 21 | Date: Sun Feb 1 09:25:10 2015 +0200 22 | 23 | Final changelog 24 | 25 | commit bd774bc3bf845c27cd70957efd92f44d52bc9687 26 | Author: Nir Simionovich 27 | Date: Sun Feb 1 09:22:38 2015 +0200 28 | 29 | Experiment with new changelog format 30 | 31 | commit a92e0c2360453d056255e3b2d5260f4cac06cfaf 32 | Author: Nir Simionovich 33 | Date: Sun Feb 1 09:17:49 2015 +0200 34 | 35 | CHANGELOG format now changed to something more readable 36 | 37 | commit fb0128dc2d94c6e35671ea322ba5206063c44be4 38 | Author: Nir Simionovich 39 | Date: Sun Feb 1 09:16:56 2015 +0200 40 | 41 | Change method from DELETE to POST for channel removal from bridge function (bridges->delchannel) - Reported by Mark Ingles 42 | 43 | Mark Ingles 44 | 7:45 PM (13 hours ago) 45 | 46 | to greenfieldtech. 47 | Hi, 48 | in release-3/src/interfaces/bridges.php line 280, inside the function delchannel, this line: 49 | $result = $this->pestObject->delete($uri, $delObj); 50 | 51 | should be 52 | $result = $this->pestObject->post($uri, $delObj); 53 | 54 | The HTTP method should be post, not delete. Or else ARI will return "Invalid method" 55 | This error is in the prior versions too. 56 | 57 | Reference: https://wiki.asterisk.org/wiki/display/AST/Asterisk+13+Bridges+REST+API#Asterisk13BridgesRESTAPI-removeChannel 58 | 59 | Thanks - Mark Ingles 60 | 61 | commit 85e7e4805037a5be879a07a803737c0f1ae95632 62 | Author: Nir Simionovich 63 | Date: Tue Dec 30 09:09:21 2014 +0200 64 | 65 | More styling clean ups and corrections to several of the class libraries. Code compacting in progress, stop copying things around and make things tighter and nicer. 66 | 67 | commit afb3dfc92f91cf23802a38781ceb651be6e0b65a 68 | Author: Nir Simionovich 69 | Date: Sun Dec 28 12:07:57 2014 +0200 70 | 71 | More API clean ups and some styling fixes :-) 72 | 73 | commit eb3a17d6a2ed5a815aaf0145c2639e3acef3d774 74 | Author: Nir Simionovich 75 | Date: Sun Dec 28 11:37:51 2014 +0200 76 | 77 | More API clean ups - devicestates, endpoints, events, mailboxes and playbacks 78 | 79 | commit b6315568975f245a8d6a378bb092260970031edc 80 | Author: Nir Simionovich 81 | Date: Sun Dec 28 08:25:31 2014 +0200 82 | 83 | Asterisk REST API changes, Bridges REST API changes: 84 | 85 | Resolve API definition differences between the ARI specification and PHPARI implementation - we now follow the original API definition, as defined in 86 | https://wiki.asterisk.org/wiki/display/AST/Asterisk+12+Bridges+REST+API 87 | 88 | In addition, API function had changed, with creation of function aliasing for previous version - these will go away in version 2.0 89 | 90 | commit 6cdf6d23c2c429b3e82f374ddf1a9f399197bbf6 91 | Merge: 8cca54e 56bf23a 92 | Author: Nir Simionovich 93 | Date: Mon Nov 10 13:49:45 2014 +0200 94 | 95 | Merge pull request #29 from greenfieldtech-nirs/master 96 | 97 | Merging back from Master changes over Develop branch 98 | 99 | commit 56bf23aded08c75a4e2bbd1b2d6523ec4e334715 100 | Author: Nir Simionovich 101 | Date: Mon Nov 10 12:43:27 2014 +0200 102 | 103 | Commit a small styling fix - NetBeans can be tricky some times 104 | 105 | commit 8cca54e08cfd6be3ef78b2910bd1ae9d32e82574 106 | Author: Nir Simionovich 107 | Date: Mon Nov 10 12:41:18 2014 +0200 108 | 109 | This is a partial commit - the code is most probably broken right now :-( 110 | 111 | commit 5ed40e2e7957cd196c80e230ba38c53449356d9f 112 | Merge: ac794cc 00971cc 113 | Author: Nir Simionovich 114 | Date: Mon Nov 10 12:07:51 2014 +0200 115 | 116 | Merge pull request #28 from matak/master 117 | 118 | Accepting merge #28: 119 | 1. Additional Class Documentations for IDE readability - @matak 120 | 2. Class initiation sanity checking and verification - @matak 121 | 122 | commit 00971ccdfff111d1c00a302f5d992ed5d7208afb 123 | Author: Roman Matěna 124 | Date: Mon Nov 10 11:00:35 2014 +0100 125 | 126 | comments for IDE, variable check if declare 127 | 128 | instance of interfaces is instanciated only once, added comments to 129 | variables for IDE 130 | 131 | commit ac794cc84cba5ac339d59d04e3b15970c374d797 132 | Merge: ebe0f6c e5a5cfb 133 | Author: Nir Simionovich 134 | Date: Mon Nov 10 09:37:41 2014 +0200 135 | 136 | Merge pull request #26 from matak/master 137 | 138 | Some fields were set as mandatory while they were optional (@matak) 139 | Some additional comments to make some of the variables in the class more readable (@matak) 140 | 141 | commit e5a5cfb74576fe624ac718d2a456da7cf8285503 142 | Author: Roman Matěna 143 | Date: Sun Nov 9 12:03:19 2014 +0100 144 | 145 | added comments, type of variables in phpari 146 | 147 | commit a4317d090c116a1d7c14f94cc53639021f561849 148 | Author: Roman Matěna 149 | Date: Sun Nov 9 11:52:56 2014 +0100 150 | 151 | comments improved, type of variables 152 | 153 | added variable type logger and loopinterface, logwriter is not attached 154 | and stored to object, why to store logwriter to phpari object? 155 | 156 | commit d2d5d89273871f33f2e15b8d00708140b061da3a 157 | Author: Roman Matěna 158 | Date: Sun Nov 9 09:43:50 2014 +0100 159 | 160 | lang and format is not mandatory parameters 161 | 162 | for good working you dont have to set these parameters 163 | 164 | commit ebe0f6c423a98b7393fa9d02968fadb8ee59fb92 165 | Author: Nir Simionovich 166 | Date: Sun Nov 9 09:04:29 2014 +0200 167 | 168 | Update README.md 169 | 170 | commit 41996a80c47401f2a955fb073a4b4d7abbf04922 171 | Merge: e349ba3 11f8f59 172 | Author: Nir Simionovich 173 | Date: Sun Nov 9 08:58:20 2014 +0200 174 | 175 | Merge pull request #25 from matak/master 176 | 177 | Resolve a small regression issue - class init wasn't using the proper Endpoint configuration 178 | 179 | commit 11f8f598b46fc553442d4a3043b5023b77664efe 180 | Author: Roman Matěna 181 | Date: Fri Nov 7 17:56:56 2014 +0100 182 | 183 | Fixes #24 184 | 185 | commit e349ba3bea1cc77e5ed6076cad3bae760b8ba72a 186 | Merge: fa52565 c67803e 187 | Author: Nir Simionovich 188 | Date: Thu Oct 23 17:21:05 2014 +0300 189 | 190 | Merge pull request #23 from greenfieldtech-nirs/develop 191 | 192 | Bug fix from community contribution Tonils@GitHub 193 | 194 | commit fa525654c5e97111808dc0550a397fe011e0bf3f 195 | Author: Nir Simionovich 196 | Date: Thu Oct 23 17:20:03 2014 +0300 197 | 198 | Regression fixes - we had a minor issues with improper handling of REST errors across the board. 199 | This has now been resolved and reflected into the BasisStasisApplication example. 200 | 201 | commit c67803e5656ae45110ec38bab696cd395081ed64 202 | Author: Nir Simionovich 203 | Date: Thu Oct 23 03:56:52 2014 +0300 204 | 205 | Bug fix from community contribution Tonils@GitHub 206 | 207 | commit 546f806f43632f5625f790620638ca84cd363a66 208 | Merge: 2f94087 c01d0eb 209 | Author: Nir Simionovich 210 | Date: Thu Oct 23 03:54:24 2014 +0300 211 | 212 | Merge pull request #22 from MattRiddell/master 213 | 214 | Parameters are now specified in the config file 215 | 216 | commit c01d0ebe87a0f36f13ab0f21eef73c006f46a60f 217 | Author: Matt 218 | Date: Wed Oct 22 14:32:18 2014 -0700 219 | 220 | Parameters are now specified in the config file 221 | 222 | commit 2f9408719a824d631d80fb7145b75f9f50a43f1c 223 | Merge: 2273af5 997fe5b 224 | Author: Nir Simionovich 225 | Date: Wed Oct 22 19:45:34 2014 +0300 226 | 227 | Merge pull request #20 from greenfieldtech-nirs/develop 228 | 229 | Develop 230 | 231 | commit 997fe5be9c9880fc1582c3b93ec624b44e5336e8 232 | Author: Nir Simionovich 233 | Date: Tue Oct 21 20:00:21 2014 +0300 234 | 235 | remove the old logger which is no longer required. Added a new parsing class, to enable the unifying of input into channels and other APIs. 236 | Channel API data input had changed, we are now able to accept free form input. 237 | 238 | commit a24dd720b2fbc64c9ac70c4e3ad4816baba60f53 239 | Author: Nir Simionovich 240 | Date: Sat Oct 11 22:49:28 2014 +0300 241 | 242 | Added contrib directory for init scripts and other contributions, not directly related to the PHPARI code. 243 | 244 | commit 5493ca0e2484ace5b8338b92e83cce060896706c 245 | Author: Nir Simionovich 246 | Date: Thu Oct 9 14:40:03 2014 +0300 247 | 248 | We now have a proper CHANGELOG in here 249 | 250 | commit 2273af5bc6a0f652813f20db5f7cbc1c976ca0da 251 | Merge: 988b128 a2e1bf1 252 | Author: Nir Simionovich 253 | Date: Thu Oct 9 14:09:15 2014 +0300 254 | 255 | Merge pull request #19 from greenfieldtech-nirs/develop 256 | 257 | Merging back from development 258 | 259 | commit a2e1bf122743b4ef04acb74e367bb4c4f5c5bda7 260 | Merge: 3dd26e8 6a9b165 261 | Author: Nir Simionovich 262 | Date: Thu Oct 9 14:07:19 2014 +0300 263 | 264 | Merge branch 'feature/Proper-Error-Reporting' into develop 265 | 266 | commit 6a9b1653e526bbef4ae66d9a5ba3f8782ec9163f 267 | Author: Nir Simionovich 268 | Date: Thu Oct 9 14:07:02 2014 +0300 269 | 270 | Add additional information to the README, reflecting the latest changes and some more information about how to write a Stasis application using PHPARI. 271 | 272 | commit d2abdebad8b67a66d75f7b49411c47feb22d5f1b 273 | Author: Nir Simionovich 274 | Date: Thu Oct 9 13:58:21 2014 +0300 275 | 276 | We now populate "lasterror" and "lasttrace" object variables, to enable better visibility of errors that may occur while working with the class. 277 | Spring cleaning was performed on some of the files, so that the code is more readable. 278 | 279 | commit 3dd26e8587d65ef56f596a9be43ad40338ccbf01 280 | Merge: 0f99e52 0551c90 281 | Author: Nir Simionovich 282 | Date: Thu Oct 9 12:59:56 2014 +0300 283 | 284 | Merge pull request #18 from greenfieldtech-nirs/Proper-Event-Handling 285 | 286 | Pull #5 - Proper event handling 287 | 288 | commit 0551c901f8c12cf0ee483671496946180e49b69f 289 | Author: Nir Simionovich 290 | Date: Thu Oct 9 12:59:01 2014 +0300 291 | 292 | Modified all example application to work with the class invocation and configuration method. 293 | 294 | commit 9bb9dc23c15290d0152f04bbad99f6d03a8d2cdd 295 | Author: Nir Simionovich 296 | Date: Thu Oct 9 12:40:51 2014 +0300 297 | 298 | Oops, previous commit didn't come in fully - silly SourceTree 299 | 300 | commit a04d65aa5dedee85a828a19e7095b5fe3d1f6edf 301 | Author: Nir Simionovich 302 | Date: Thu Oct 9 12:31:33 2014 +0300 303 | 304 | Configuration is important - we've migrated the configuration of the class from the constructor over to an external 305 | configuration file, default is phpari.ini. The current file also has future reference for an AGI and AMI connector, 306 | but these will come later on. Debug logging is performed via the Zend Logger class, which is part of PHPARI. 307 | - TODO: Modify the examples 308 | - TODO: Add better visibility of errors during PEST requests 309 | 310 | commit 0f99e523d3357a7b690b23d7d4bd06d9b3691097 311 | Author: Nir Simionovich 312 | Date: Wed Oct 8 16:38:07 2014 +0300 313 | 314 | Commit additional channels API handling 315 | 316 | commit b589f54bc64f3ce879ca70d8816c85e3a740137a 317 | Merge: afe8dc4 a5f1573 318 | Author: Nir Simionovich 319 | Date: Mon Oct 6 10:50:24 2014 +0300 320 | 321 | Merge branch 'develop' of https://github.com/greenfieldtech-nirs/phpari into develop 322 | 323 | commit a5f15731266be99cab025f0ecfa8a15c7f4fa4e3 324 | Author: Nir Simionovich 325 | Date: Mon Oct 6 08:29:25 2014 +0300 326 | 327 | Commit the playbacks class - modify the basic Stasis example to something a bit more meaningful. 328 | 329 | commit 988b1284cb3d30c779acd1b69fc82a0a328bf920 330 | Merge: 0568521 afe8dc4 331 | Author: Nir Simionovich 332 | Date: Thu Sep 18 11:08:13 2014 +0300 333 | 334 | Merge pull request #16 from greenfieldtech-nirs/develop 335 | 336 | Fix constructor interfaces to extended classes 337 | 338 | commit afe8dc495cd62e9067bf93372610527b33378404 339 | Author: Nir Simionovich 340 | Date: Thu Sep 18 11:06:56 2014 +0300 341 | 342 | Some of our interfaces were mis-implementing the __construct function. This is now updated to reflect a unified constructor for all extension classes. 343 | 344 | commit 0568521b63ea5f3130b58317c87ff4b3de47c04a 345 | Merge: b5f4069 93e847a 346 | Author: Nir Simionovich 347 | Date: Thu Sep 18 09:28:48 2014 +0300 348 | 349 | Merge pull request #15 from greenfieldtech-nirs/develop 350 | 351 | Commit a slightly more detailed README.md file, so that people can actua... 352 | 353 | commit 93e847a5f705ba183dfb88e6e7f16c9b0a6bfc46 354 | Author: Nir Simionovich 355 | Date: Thu Sep 18 09:28:41 2014 +0300 356 | 357 | Commit a slightly more detailed README.md file, so that people can actually start doing something with phpari :-) 358 | 359 | commit b5f40690497666715fb39e47f20702029c0f032b 360 | Merge: bafdefb 04b7e5b 361 | Author: Nir Simionovich 362 | Date: Thu Sep 18 09:02:46 2014 +0300 363 | 364 | Merge pull request #14 from greenfieldtech-nirs/develop 365 | 366 | phpStorm can so picky at times :-( 367 | 368 | commit 04b7e5b3354fbe49e5fb0120ddafc56f33b7c343 369 | Author: Nir Simionovich 370 | Date: Thu Sep 18 09:02:42 2014 +0300 371 | 372 | phpStorm can so picky at times :-( 373 | 374 | commit bafdefb3f2879a9a9e5a50918af85408b7bf0f4c 375 | Merge: 40c8615 bdb53a1 376 | Author: Nir Simionovich 377 | Date: Thu Sep 18 09:01:06 2014 +0300 378 | 379 | Merge pull request #13 from greenfieldtech-nirs/develop 380 | 381 | looks like the .idea folder got committed for some reason - that is just... 382 | 383 | commit bdb53a148e022ef5ea0f6447a31ce593bc636d4f 384 | Author: Nir Simionovich 385 | Date: Thu Sep 18 08:59:52 2014 +0300 386 | 387 | looks like the .idea folder got committed for some reason - that is just not supposed to be there. 388 | 389 | commit 40c86150665f2d8d1195deea0d49f9a06ef13653 390 | Merge: 3608465 0e8982f 391 | Author: Nir Simionovich 392 | Date: Wed Sep 17 21:08:10 2014 +0300 393 | 394 | Merge pull request #12 from greenfieldtech-nirs/develop 395 | 396 | Slight formatting fix - is was simply looking really bad previously 397 | 398 | commit 0e8982f75d1358cd4668ba05d0ea98f3e209c06b 399 | Author: Nir Simionovich 400 | Date: Wed Sep 17 21:06:54 2014 +0300 401 | 402 | Slight formatting fix - is was simply looking really bad previously 403 | 404 | commit 36084658f47279a125a58de69038ba4400a5afa5 405 | Merge: 5282fc9 fe82457 406 | Author: Nir Simionovich 407 | Date: Wed Sep 17 14:04:15 2014 +0300 408 | 409 | Merge pull request #11 from greenfieldtech-nirs/develop 410 | 411 | Merging back from development fixed branch to master 412 | 413 | commit fe82457ecdc4936297e034c850171248c803a447 414 | Author: Nir Simionovich 415 | Date: Wed Sep 17 14:02:37 2014 +0300 416 | 417 | oops, we should also ignore composer.lock 418 | 419 | commit c17066393b83f3329c1b5bd76299c63f45a0532b 420 | Author: Nir Simionovich 421 | Date: Wed Sep 17 14:02:00 2014 +0300 422 | 423 | .gitignore got trashed slightly, fixing and recommitting 424 | 425 | commit 3f3bc38a06313a0d200a47c694291a5fb8037e4c 426 | Author: Nir Simionovich 427 | Date: Wed Sep 17 13:58:59 2014 +0300 428 | 429 | Oops, somebody committed and pushed the vendor directory 430 | 431 | commit c8edbd2e8f6ec7455dab30412ceb53ab1f55393e 432 | Merge: b8de977 5282fc9 433 | Author: Nir Simionovich 434 | Date: Wed Sep 17 13:55:31 2014 +0300 435 | 436 | Merge pull request #10 from greenfieldtech-nirs/master 437 | 438 | Merging back from Master to Develop - Completed 439 | 440 | commit 5282fc99c26356e9d97af85e9e9459f470c551fc 441 | Merge: 38756dc 8f04273 442 | Author: Nir Simionovich 443 | Date: Wed Sep 17 13:53:14 2014 +0300 444 | 445 | Merge pull request #9 from leonidies/master 446 | 447 | Changed ARI/Stasis functional access methodology within the code, better class manipulation and an easier interface 448 | 449 | commit 8f04273316e4f2d0cdf104078db22b7c454b1b7e 450 | Author: leonid 451 | Date: Wed Sep 17 13:42:44 2014 +0300 452 | 453 | A liitle more completed code for the ARI (the php ari became cleaner) 454 | 455 | commit de4d5a7c865e203490e6c8da0d659c29fb5d5b89 456 | Author: leonid 457 | Date: Wed Sep 17 12:31:50 2014 +0300 458 | 459 | Merged call from greenfieldtech phpari repository 460 | 461 | commit 8566cea8f7b4030224e43d00dd7579e407bd34dd 462 | Author: leonid 463 | Date: Wed Sep 17 12:11:57 2014 +0300 464 | 465 | no message 466 | 467 | commit afffe6638b1dbd0a9081c804bcba21536664bd23 468 | Author: leonid 469 | Date: Wed Sep 17 12:11:36 2014 +0300 470 | 471 | no message 472 | 473 | commit 70ade542fa3a58a69989fc66d28f2b8560c454f0 474 | Author: leonid 475 | Date: Wed Sep 17 12:06:44 2014 +0300 476 | 477 | The first version after the fork from Nir's repository 478 | 479 | commit 38756dc0a3a4a00a306b299b7ccdd1ed76c243c4 480 | Merge: edae18e b8de977 481 | Author: greenfieldtech-nirs 482 | Date: Wed Sep 10 20:25:43 2014 +0300 483 | 484 | Merge pull request #7 from greenfieldtech-nirs/develop 485 | 486 | Merging back to Master from Development branch - clean ups mainly 487 | 488 | commit b8de977cf4db9958fdc1615fe230334adb60fb44 489 | Author: Nir Simionovich 490 | Date: Wed Sep 10 20:21:37 2014 +0300 491 | 492 | Minor Cleanups 493 | 494 | commit a021156057112a3b2fc29d69b4cbbf4c2e1a4d57 495 | Author: Nir Simionovich 496 | Date: Wed Sep 10 20:08:15 2014 +0300 497 | 498 | Ok, so we did a little mistake in the LICENSE file, and we modified it to LGPL 2.1 instead of GPL 2. 499 | Copyright and License notices had been added to the core library files. 500 | 501 | commit 2d1d4a258e0d71d3fcd9e1256912aee2831e2f28 502 | Merge: f757f1c edae18e 503 | Author: Nir Simionovich 504 | Date: Wed Sep 10 16:12:08 2014 +0300 505 | 506 | Merge branch 'master' into develop 507 | 508 | commit edae18e28cc88b4b37a98a6a5e5bb279285fa191 509 | Merge: a7e0457 e73fb29 510 | Author: greenfieldtech-nirs 511 | Date: Wed Sep 10 16:05:08 2014 +0300 512 | 513 | Merge pull request #6 from leonidies/master 514 | 515 | Merging current development version back into primary repository. 516 | - Added additional code examples 517 | - composer.json updated to support packagist 518 | - Improved class design 519 | 520 | commit e73fb297629762bc400b560f442b0929b1779eb9 521 | Author: leonid 522 | Date: Wed Sep 10 14:51:55 2014 +0300 523 | 524 | The cancel call was added 525 | 526 | commit 9fca91d91ffc849dfda9ffa83f0a28d9ea4bf154 527 | Author: leonid 528 | Date: Wed Sep 10 13:29:48 2014 +0300 529 | 530 | This is emproved version of the phpari with new interfaces 531 | 532 | commit 04392d0fd30f5c371b87c38c643bd546a0aad101 533 | Author: leonid 534 | Date: Wed Sep 10 13:10:14 2014 +0300 535 | 536 | This is basics and examples 537 | 538 | commit 3542ab094378b8df26fb00c15789bb34d14152d0 539 | Author: leonid 540 | Date: Wed Sep 10 11:24:56 2014 +0300 541 | 542 | Interfaces has been added 543 | 544 | commit f757f1cbee2895972b8c6dc61fbf9b5fcf5aca50 545 | Author: Nir Simionovich 546 | Date: Sun Sep 7 18:41:00 2014 +0300 547 | 548 | Minor commit to verify push - disregard this one 549 | 550 | commit a7e0457a2c50706428294d3bf354ae238b8e50f9 551 | Merge: 9c18e4b d9d94be 552 | Author: greenfieldtech-nirs 553 | Date: Sun Sep 7 18:28:30 2014 +0300 554 | 555 | Merge pull request #3 from leonidies/master 556 | 557 | The channels interface ready , need to be tested 558 | 559 | commit d9d94be9e08e42bc8fbce9b5a4ed0e8962aa84c7 560 | Author: leonid 561 | Date: Sun Sep 7 18:26:21 2014 +0300 562 | 563 | The channels interface ready , need to be tested . 564 | 565 | commit 9c18e4bf276e4f0bee27fa7e7255fcb9bca3818f 566 | Merge: e66d983 af58020 567 | Author: greenfieldtech-nirs 568 | Date: Sat Sep 6 02:35:29 2014 +0300 569 | 570 | Merge pull request #2 from greenfieldtech-nirs/develop 571 | 572 | small change to composer json 573 | 574 | commit af58020b3c7efa1ca470fdc2a0b4cdd995b47593 575 | Author: Nir Simionovich 576 | Date: Sat Sep 6 02:34:39 2014 +0300 577 | 578 | small change to composer json 579 | 580 | commit e66d98386d82fdc63651c0bd68c785b3d2557840 581 | Merge: 2b2a6a9 50316bc 582 | Author: greenfieldtech-nirs 583 | Date: Sat Sep 6 02:24:14 2014 +0300 584 | 585 | Merge pull request #1 from greenfieldtech-nirs/develop 586 | 587 | Basic ARI Class defined with proper boot strapping. 588 | 589 | commit 50316bc6df28570eceabb5f346358b60072a4b55 590 | Author: Nir Simionovich 591 | Date: Sat Sep 6 02:21:41 2014 +0300 592 | 593 | Basic ARI Class defined with proper boot strapping. 594 | 595 | Basic usage example included. 596 | 597 | TODO: Build all ARI interfaces 598 | 599 | commit 2b2a6a9cef47e71ac75e06b788edb33be585b46c 600 | Author: greenfieldtech-nirs 601 | Date: Thu Sep 4 08:26:53 2014 +0300 602 | 603 | Initial commit 604 | -------------------------------------------------------------------------------- /CHANGELOG.MD: -------------------------------------------------------------------------------- 1 | [http://github.com/greenfieldtech-nirs/phpari/commit/bd774bc3bf845c27cd70957efd92f44d52bc9687] Experiment with new changelog format 2 | [http://github.com/greenfieldtech-nirs/phpari/commit/a92e0c2360453d056255e3b2d5260f4cac06cfaf] CHANGELOG format now changed to something more readable 3 | [http://github.com/greenfieldtech-nirs/phpari/commit/fb0128dc2d94c6e35671ea322ba5206063c44be4] Change method from DELETE to POST for channel removal from bridge function (bridges->delchannel) - Reported by Mark Ingles 4 | [http://github.com/greenfieldtech-nirs/phpari/commit/85e7e4805037a5be879a07a803737c0f1ae95632] More styling clean ups and corrections to several of the class libraries. Code compacting in progress, stop copying things around and make things tighter and nicer. 5 | [http://github.com/greenfieldtech-nirs/phpari/commit/afb3dfc92f91cf23802a38781ceb651be6e0b65a] More API clean ups and some styling fixes :-) 6 | [http://github.com/greenfieldtech-nirs/phpari/commit/eb3a17d6a2ed5a815aaf0145c2639e3acef3d774] More API clean ups - devicestates, endpoints, events, mailboxes and playbacks 7 | [http://github.com/greenfieldtech-nirs/phpari/commit/b6315568975f245a8d6a378bb092260970031edc] Asterisk REST API changes, Bridges REST API changes: 8 | [http://github.com/greenfieldtech-nirs/phpari/commit/6cdf6d23c2c429b3e82f374ddf1a9f399197bbf6] Merge pull request #29 from greenfieldtech-nirs/master 9 | [http://github.com/greenfieldtech-nirs/phpari/commit/56bf23aded08c75a4e2bbd1b2d6523ec4e334715] Commit a small styling fix - NetBeans can be tricky some times 10 | [http://github.com/greenfieldtech-nirs/phpari/commit/8cca54e08cfd6be3ef78b2910bd1ae9d32e82574] This is a partial commit - the code is most probably broken right now :-( 11 | [http://github.com/greenfieldtech-nirs/phpari/commit/5ed40e2e7957cd196c80e230ba38c53449356d9f] Merge pull request #28 from matak/master 12 | [http://github.com/greenfieldtech-nirs/phpari/commit/00971ccdfff111d1c00a302f5d992ed5d7208afb] comments for IDE, variable check if declare 13 | [http://github.com/greenfieldtech-nirs/phpari/commit/ac794cc84cba5ac339d59d04e3b15970c374d797] Merge pull request #26 from matak/master 14 | [http://github.com/greenfieldtech-nirs/phpari/commit/e5a5cfb74576fe624ac718d2a456da7cf8285503] added comments, type of variables in phpari 15 | [http://github.com/greenfieldtech-nirs/phpari/commit/a4317d090c116a1d7c14f94cc53639021f561849] comments improved, type of variables 16 | [http://github.com/greenfieldtech-nirs/phpari/commit/d2d5d89273871f33f2e15b8d00708140b061da3a] lang and format is not mandatory parameters 17 | [http://github.com/greenfieldtech-nirs/phpari/commit/ebe0f6c423a98b7393fa9d02968fadb8ee59fb92] Update README.md 18 | [http://github.com/greenfieldtech-nirs/phpari/commit/41996a80c47401f2a955fb073a4b4d7abbf04922] Merge pull request #25 from matak/master 19 | [http://github.com/greenfieldtech-nirs/phpari/commit/11f8f598b46fc553442d4a3043b5023b77664efe] Fixes #24 20 | [http://github.com/greenfieldtech-nirs/phpari/commit/e349ba3bea1cc77e5ed6076cad3bae760b8ba72a] Merge pull request #23 from greenfieldtech-nirs/develop 21 | [http://github.com/greenfieldtech-nirs/phpari/commit/fa525654c5e97111808dc0550a397fe011e0bf3f] Regression fixes - we had a minor issues with improper handling of REST errors across the board. This has now been resolved and reflected into the BasisStasisApplication example. 22 | [http://github.com/greenfieldtech-nirs/phpari/commit/c67803e5656ae45110ec38bab696cd395081ed64] Bug fix from community contribution Tonils@GitHub 23 | [http://github.com/greenfieldtech-nirs/phpari/commit/546f806f43632f5625f790620638ca84cd363a66] Merge pull request #22 from MattRiddell/master 24 | [http://github.com/greenfieldtech-nirs/phpari/commit/c01d0ebe87a0f36f13ab0f21eef73c006f46a60f] Parameters are now specified in the config file 25 | [http://github.com/greenfieldtech-nirs/phpari/commit/2f9408719a824d631d80fb7145b75f9f50a43f1c] Merge pull request #20 from greenfieldtech-nirs/develop 26 | [http://github.com/greenfieldtech-nirs/phpari/commit/997fe5be9c9880fc1582c3b93ec624b44e5336e8] remove the old logger which is no longer required. Added a new parsing class, to enable the unifying of input into channels and other APIs. Channel API data input had changed, we are now able to accept free form input. 27 | [http://github.com/greenfieldtech-nirs/phpari/commit/a24dd720b2fbc64c9ac70c4e3ad4816baba60f53] Added contrib directory for init scripts and other contributions, not directly related to the PHPARI code. 28 | [http://github.com/greenfieldtech-nirs/phpari/commit/5493ca0e2484ace5b8338b92e83cce060896706c] We now have a proper CHANGELOG in here 29 | [http://github.com/greenfieldtech-nirs/phpari/commit/2273af5bc6a0f652813f20db5f7cbc1c976ca0da] Merge pull request #19 from greenfieldtech-nirs/develop 30 | [http://github.com/greenfieldtech-nirs/phpari/commit/a2e1bf122743b4ef04acb74e367bb4c4f5c5bda7] Merge branch 'feature/Proper-Error-Reporting' into develop 31 | [http://github.com/greenfieldtech-nirs/phpari/commit/6a9b1653e526bbef4ae66d9a5ba3f8782ec9163f] Add additional information to the README, reflecting the latest changes and some more information about how to write a Stasis application using PHPARI. 32 | [http://github.com/greenfieldtech-nirs/phpari/commit/d2abdebad8b67a66d75f7b49411c47feb22d5f1b] We now populate "lasterror" and "lasttrace" object variables, to enable better visibility of errors that may occur while working with the class. Spring cleaning was performed on some of the files, so that the code is more readable. 33 | [http://github.com/greenfieldtech-nirs/phpari/commit/3dd26e8587d65ef56f596a9be43ad40338ccbf01] Merge pull request #18 from greenfieldtech-nirs/Proper-Event-Handling 34 | [http://github.com/greenfieldtech-nirs/phpari/commit/0551c901f8c12cf0ee483671496946180e49b69f] Modified all example application to work with the class invocation and configuration method. 35 | [http://github.com/greenfieldtech-nirs/phpari/commit/9bb9dc23c15290d0152f04bbad99f6d03a8d2cdd] Oops, previous commit didn't come in fully - silly SourceTree 36 | [http://github.com/greenfieldtech-nirs/phpari/commit/a04d65aa5dedee85a828a19e7095b5fe3d1f6edf] Configuration is important - we've migrated the configuration of the class from the constructor over to an external configuration file, default is phpari.ini. The current file also has future reference for an AGI and AMI connector, but these will come later on. Debug logging is performed via the Zend Logger class, which is part of PHPARI. - TODO: Modify the examples - TODO: Add better visibility of errors during PEST requests 37 | [http://github.com/greenfieldtech-nirs/phpari/commit/0f99e523d3357a7b690b23d7d4bd06d9b3691097] Commit additional channels API handling 38 | [http://github.com/greenfieldtech-nirs/phpari/commit/b589f54bc64f3ce879ca70d8816c85e3a740137a] Merge branch 'develop' of https://github.com/greenfieldtech-nirs/phpari into develop 39 | [http://github.com/greenfieldtech-nirs/phpari/commit/a5f15731266be99cab025f0ecfa8a15c7f4fa4e3] Commit the playbacks class - modify the basic Stasis example to something a bit more meaningful. 40 | [http://github.com/greenfieldtech-nirs/phpari/commit/988b1284cb3d30c779acd1b69fc82a0a328bf920] Merge pull request #16 from greenfieldtech-nirs/develop 41 | [http://github.com/greenfieldtech-nirs/phpari/commit/afe8dc495cd62e9067bf93372610527b33378404] Some of our interfaces were mis-implementing the __construct function. This is now updated to reflect a unified constructor for all extension classes. 42 | [http://github.com/greenfieldtech-nirs/phpari/commit/0568521b63ea5f3130b58317c87ff4b3de47c04a] Merge pull request #15 from greenfieldtech-nirs/develop 43 | [http://github.com/greenfieldtech-nirs/phpari/commit/93e847a5f705ba183dfb88e6e7f16c9b0a6bfc46] Commit a slightly more detailed README.md file, so that people can actually start doing something with phpari :-) 44 | [http://github.com/greenfieldtech-nirs/phpari/commit/b5f40690497666715fb39e47f20702029c0f032b] Merge pull request #14 from greenfieldtech-nirs/develop 45 | [http://github.com/greenfieldtech-nirs/phpari/commit/04b7e5b3354fbe49e5fb0120ddafc56f33b7c343] phpStorm can so picky at times :-( 46 | [http://github.com/greenfieldtech-nirs/phpari/commit/bafdefb3f2879a9a9e5a50918af85408b7bf0f4c] Merge pull request #13 from greenfieldtech-nirs/develop 47 | [http://github.com/greenfieldtech-nirs/phpari/commit/bdb53a148e022ef5ea0f6447a31ce593bc636d4f] looks like the .idea folder got committed for some reason - that is just not supposed to be there. 48 | [http://github.com/greenfieldtech-nirs/phpari/commit/40c86150665f2d8d1195deea0d49f9a06ef13653] Merge pull request #12 from greenfieldtech-nirs/develop 49 | [http://github.com/greenfieldtech-nirs/phpari/commit/0e8982f75d1358cd4668ba05d0ea98f3e209c06b] Slight formatting fix - is was simply looking really bad previously 50 | [http://github.com/greenfieldtech-nirs/phpari/commit/36084658f47279a125a58de69038ba4400a5afa5] Merge pull request #11 from greenfieldtech-nirs/develop 51 | [http://github.com/greenfieldtech-nirs/phpari/commit/fe82457ecdc4936297e034c850171248c803a447] oops, we should also ignore composer.lock 52 | [http://github.com/greenfieldtech-nirs/phpari/commit/c17066393b83f3329c1b5bd76299c63f45a0532b] .gitignore got trashed slightly, fixing and recommitting 53 | [http://github.com/greenfieldtech-nirs/phpari/commit/3f3bc38a06313a0d200a47c694291a5fb8037e4c] Oops, somebody committed and pushed the vendor directory 54 | [http://github.com/greenfieldtech-nirs/phpari/commit/c8edbd2e8f6ec7455dab30412ceb53ab1f55393e] Merge pull request #10 from greenfieldtech-nirs/master 55 | [http://github.com/greenfieldtech-nirs/phpari/commit/5282fc99c26356e9d97af85e9e9459f470c551fc] Merge pull request #9 from leonidies/master 56 | [http://github.com/greenfieldtech-nirs/phpari/commit/8f04273316e4f2d0cdf104078db22b7c454b1b7e] A liitle more completed code for the ARI (the php ari became cleaner) 57 | [http://github.com/greenfieldtech-nirs/phpari/commit/de4d5a7c865e203490e6c8da0d659c29fb5d5b89] Merged call from greenfieldtech phpari repository 58 | [http://github.com/greenfieldtech-nirs/phpari/commit/8566cea8f7b4030224e43d00dd7579e407bd34dd] no message 59 | [http://github.com/greenfieldtech-nirs/phpari/commit/afffe6638b1dbd0a9081c804bcba21536664bd23] no message 60 | [http://github.com/greenfieldtech-nirs/phpari/commit/70ade542fa3a58a69989fc66d28f2b8560c454f0] The first version after the fork from Nir's repository 61 | [http://github.com/greenfieldtech-nirs/phpari/commit/38756dc0a3a4a00a306b299b7ccdd1ed76c243c4] Merge pull request #7 from greenfieldtech-nirs/develop 62 | [http://github.com/greenfieldtech-nirs/phpari/commit/b8de977cf4db9958fdc1615fe230334adb60fb44] Minor Cleanups 63 | [http://github.com/greenfieldtech-nirs/phpari/commit/a021156057112a3b2fc29d69b4cbbf4c2e1a4d57] Ok, so we did a little mistake in the LICENSE file, and we modified it to LGPL 2.1 instead of GPL 2. Copyright and License notices had been added to the core library files. 64 | [http://github.com/greenfieldtech-nirs/phpari/commit/2d1d4a258e0d71d3fcd9e1256912aee2831e2f28] Merge branch 'master' into develop 65 | [http://github.com/greenfieldtech-nirs/phpari/commit/edae18e28cc88b4b37a98a6a5e5bb279285fa191] Merge pull request #6 from leonidies/master 66 | [http://github.com/greenfieldtech-nirs/phpari/commit/e73fb297629762bc400b560f442b0929b1779eb9] The cancel call was added 67 | [http://github.com/greenfieldtech-nirs/phpari/commit/9fca91d91ffc849dfda9ffa83f0a28d9ea4bf154] This is emproved version of the phpari with new interfaces 68 | [http://github.com/greenfieldtech-nirs/phpari/commit/04392d0fd30f5c371b87c38c643bd546a0aad101] This is basics and examples 69 | [http://github.com/greenfieldtech-nirs/phpari/commit/3542ab094378b8df26fb00c15789bb34d14152d0] Interfaces has been added 70 | [http://github.com/greenfieldtech-nirs/phpari/commit/f757f1cbee2895972b8c6dc61fbf9b5fcf5aca50] Minor commit to verify push - disregard this one 71 | [http://github.com/greenfieldtech-nirs/phpari/commit/a7e0457a2c50706428294d3bf354ae238b8e50f9] Merge pull request #3 from leonidies/master 72 | [http://github.com/greenfieldtech-nirs/phpari/commit/d9d94be9e08e42bc8fbce9b5a4ed0e8962aa84c7] The channels interface ready , need to be tested . 73 | [http://github.com/greenfieldtech-nirs/phpari/commit/9c18e4bf276e4f0bee27fa7e7255fcb9bca3818f] Merge pull request #2 from greenfieldtech-nirs/develop 74 | [http://github.com/greenfieldtech-nirs/phpari/commit/af58020b3c7efa1ca470fdc2a0b4cdd995b47593] small change to composer json 75 | [http://github.com/greenfieldtech-nirs/phpari/commit/e66d98386d82fdc63651c0bd68c785b3d2557840] Merge pull request #1 from greenfieldtech-nirs/develop 76 | [http://github.com/greenfieldtech-nirs/phpari/commit/50316bc6df28570eceabb5f346358b60072a4b55] Basic ARI Class defined with proper boot strapping. 77 | [http://github.com/greenfieldtech-nirs/phpari/commit/2b2a6a9cef47e71ac75e06b788edb33be585b46c] Initial commit -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | phpari 2 | ====== 3 | 4 | A Class Library enabling Asterisk ARI functionality for PHP 5 | 6 | Dependencies 7 | ------------ 8 | These are the minimum requirements to have phpari installed on your server: 9 | 10 | ** PHP >= 5.3.9 11 | 12 | ** Composer 13 | 14 | ** PHP OpenSSL Module to connect using SSL (wss:// uris) 15 | 16 | Additional dependencies are installed via Composer, these include: 17 | 18 | ** Reactphp (http://reactphp.org/) 19 | 20 | ** ZF2 Logger (http://framework.zend.com/manual/2.0/en/modules/zend.log.overview.html) 21 | 22 | Installation 23 | ------------ 24 | The recommended method of installation is using Composer. Add the following to your composer.json file: 25 | 26 | ``` 27 | { 28 | "require": { 29 | "php": ">=5.3.9", 30 | "educoder/pest": "1.0.0", 31 | "devristo/phpws": "dev-master", 32 | "greenfieldtech-nirs/phpari": "dev-master" 33 | } 34 | } 35 | ``` 36 | 37 | We recommend using the "dev-master" version at this point in time, as we are still under heavy development and testing. 38 | 39 | Configuring phpari.ini 40 | ---------------------- 41 | The phpari.ini file is our primary configuration file. You can define your own, just make sure to initiate your phpari object correctly. 42 | The files' contents is as following: 43 | 44 | ``` 45 | [general] 46 | debug=0 47 | logfile=console ; console for direct console output, filename for file based logging 48 | 49 | [asterisk_ari] 50 | username=testuser 51 | password=testing 52 | host=your_asterisk_server_ip_or_fqdn 53 | port=your_asterisk_http_port 54 | endpoint=/ari 55 | transport=ws ; ws for none encrypted, wss for encrypted (currently, only ws is supported) 56 | 57 | [asterisk_manager] 58 | username=amiuser 59 | password=amipassword 60 | host=127.0.0.1 61 | port=5038 62 | ``` 63 | 64 | As you may notice, we already carry an Asterisk Manager configuration in there - this will be used in the future to provide 65 | an Asterisk manager connector object as well. 66 | 67 | Verify functionality 68 | -------------------- 69 | The simplest way to verify that phpari is installed correctly is by using it. Here is a minimal script to ensure you every installed correctly: 70 | 71 | ```php 72 | require_once("vendor/autoload.php"); 73 | 74 | echo "Starting ARI Connection\n"; 75 | $ariConnector = new phpari(); 76 | echo "Active Channels: " . json_encode($ariConnector->channels()->channel_list()) . "\n"; 77 | echo "Ending ARI Connection\n"; 78 | 79 | ``` 80 | 81 | The output should resemble the following: 82 | 83 | ``` 84 | [root@ari agi-bin]# php test.php 85 | Starting ARI Connection 86 | Active Channels: [] 87 | Ending ARI Connection 88 | ``` 89 | 90 | Error Handling within PHPARI 91 | -------------------- 92 | In order to allow for better error handling, we've decided to hold two variables, within the initiated phpari object. These are "lasterror" and "lasttrace". 93 | When an error occures, in any of the phpari module requests, be it a PEST error or another, an exception is thrown internally. In order not to break your applications, 94 | we will return a FALSE value, while populating the "lasterror" and "lasttrace" variables. 95 | 96 | For example: 97 | 98 | ```php 99 | try { 100 | $conn = new phpari("hello-world"); //create new object 101 | $app = new applications($conn); 102 | 103 | $result=$app->applications_list(); 104 | 105 | if ((!$result) && (count($result))) 106 | throw new Exception("phpari error occured", 503); 107 | 108 | echo json_encode($result); 109 | exit(0); 110 | 111 | } catch (Exception $e) { 112 | echo "Error: " . $conn->lasterror. "\n"; 113 | echo "Trace: " . $conn->lasttrace. "\n"; 114 | } 115 | ``` 116 | 117 | In the above case, we try to issue an "applications" GET request over to our Asterisk server. In case of an error, the 118 | applications object will return a FALSE value, while populating the "lasterror" and "lasttrace" variables. Here is a sample 119 | output, for a case where the "port" configuration is wrong, in phpari.ini: 120 | 121 | ``` 122 | $ php ApplicationList.php 123 | Error: Failed connect to 178.62.XXX.XXX:8080; No error 124 | Trace: #0 C:\Users\nirsi_000\Documents\phpari\vendor\educoder\pest\Pest.php(128): Pest->doRequest(Resource id #60) 125 | #1 C:\Users\nirsi_000\Documents\phpari\src\interfaces\applications.php(58): Pest->get('/applications') 126 | #2 C:\Users\nirsi_000\Documents\phpari\examples\ApplicationList.php(33): applications->applications_list() 127 | #3 {main} 128 | ``` 129 | 130 | Basic Stasis application programming 131 | ------------------------------------ 132 | Stasis is an event driven environment, which isn't really the native environment for PHP. However, thanks to PHP 5.3 and the React library, it is possible to write a "callback" based web socket client. 133 | The following example shows how this can be done - the complete example is under examples/BasicStasisApplication.php. 134 | 135 | First, we need to setup our basic Stasis connection to Asterisk: 136 | 137 | ```php 138 | class BasicStasisApplication 139 | { 140 | 141 | private $ariEndpoint; 142 | private $stasisClient; 143 | private $stasisLoop; 144 | private $phpariObject; 145 | private $stasisChannelID; 146 | private $dtmfSequence = ""; 147 | 148 | public $stasisLogger; 149 | 150 | public function __construct($appname = NULL) 151 | { 152 | try { 153 | if (is_null($appname)) 154 | throw new Exception("[" . __FILE__ . ":" . __LINE__ . "] Stasis application name must be defined!", 500); 155 | 156 | $this->phpariObject = new phpari($appname); 157 | 158 | $this->ariEndpoint = $this->phpariObject->ariEndpoint; 159 | $this->stasisClient = $this->phpariObject->stasisClient; 160 | $this->stasisLoop = $this->phpariObject->stasisLoop; 161 | $this->stasisLogger = $this->phpariObject->stasisLogger; 162 | $this->stasisEvents = $this->phpariObject->stasisEvents; 163 | } catch (Exception $e) { 164 | echo $e->getMessage(); 165 | exit(99); 166 | } 167 | } 168 | ``` 169 | 170 | Note this, the constructor will normally return no errors for this stage, as we are mearly building the required objects, not connecting to Asterisk yet. 171 | Now, we need to define our Stasis Connection Handler: 172 | 173 | ```php 174 | public function StasisAppConnectionHandlers() 175 | { 176 | try { 177 | $this->stasisClient->on("request", function ($headers) { 178 | $this->stasisLogger->notice("Request received!"); 179 | }); 180 | 181 | $this->stasisClient->on("handshake", function () { 182 | $this->stasisLogger->notice("Handshake received!"); 183 | }); 184 | 185 | $this->stasisClient->on("message", function ($message) { 186 | $event = json_decode($message->getData()); 187 | $this->stasisLogger->notice('Received event: ' . $event->type); 188 | $this->stasisEvents->emit($event->type, array($event)); 189 | }); 190 | 191 | } catch (Exception $e) { 192 | echo $e->getMessage(); 193 | exit(99); 194 | } 195 | } 196 | ``` 197 | 198 | Note that we will be ommiting an Event for any additional Asterisk Stasis "message" that is received. 199 | Now, we need to actually build our connection to Asterisk: 200 | 201 | ```php 202 | public function execute() 203 | { 204 | try { 205 | $this->stasisClient->open(); 206 | $this->stasisLoop->run(); 207 | } catch (Exception $e) { 208 | echo $e->getMessage(); 209 | exit(99); 210 | } 211 | } 212 | ``` 213 | 214 | Our main script body would be the following: 215 | 216 | ```php 217 | $basicAriClient = new BasicStasisApplication("hello-world"); 218 | 219 | $basicAriClient->stasisLogger->info("Starting Stasis Program... Waiting for handshake..."); 220 | $basicAriClient->StasisAppEventHandler(); 221 | 222 | $basicAriClient->stasisLogger->info("Connecting... Waiting for handshake..."); 223 | $basicAriClient->execute(); 224 | ``` 225 | 226 | That's it - this is your most basic Stasis application. We suggest that you now take a look at examples/BasicStasisApplication.php to see the entire code in action. 227 | 228 | Reporting Issues 229 | -------------------- 230 | Please report issues directly via the Github project page. 231 | 232 | Contibuting Code 233 | ---------------- 234 | We are very open when it comes to people contributing code to this project. In order to make life easier, here is the preferred method to contribute code: 235 | 236 | For bug fixes and security updates in Master branch: 237 | 238 | 1. Fork the Master Branch into your own personal Github account 239 | 2. Update your local fork 240 | 3. Generate a pull request from your own fork over to our Master Branch 241 | 242 | For new features and improvement: 243 | 244 | 1. Fork the Development Branch into your own personal Github account 245 | 2. Update your local fork 246 | 3. Generate a pull request from your own fork over to our development branch 247 | 248 | We will do our best to go over the various contributions as fast as possible. Bug fixes and security updates will be handled faster - feature improvements will be added to the next major release. 249 | 250 | Our IDE of choice is phpStorm from JetBrains (http://www.jetbrains.com/phpstorm/) - we use the default styling, so no need to change that. If you use a different IDE, please make sure you update your IDE to support the internal styling of the project, so that you don't break the general code styling. 251 | 252 | Make sure to document your code - once it's merged in, we will need to keep working on your code, so please make sure your documentation will be clear and concise, so we can continue your work (as required). 253 | 254 | Our objective is to involve the community as much as possible, so feel free to jump in and assist. Contibutions to the project will automatically put your name into the README.md file, so that everybody will see your coolness and greatness supporting the Open Source movement and the continuation of this project. 255 | 256 | Release Policy 257 | -------------- 258 | Releasing code into the Open Source is always a challenge, it can be both confusing and dawnting at the same time. In order to make life simple with version numbers, here is our projected release policy (it may change in the future). 259 | 260 | Every version will be marked with a Major.Minor.Patch version numbering scheme. 261 | 262 | A major release will be released once the code of the library is stable and battle tested. How long does that take? good question, we don't know. Currently, our major release version is 0 - we are still in active development. 263 | 264 | A minor release will be released once the code of the library is stable and had been introduced with a significant number of fixes and modifications, and been regressed by several members of the community. 265 | 266 | A patch release will be released once the code of the library is stable and had been introduced with minor modifications. These modifications will normally include bug fixes and security updates. 267 | 268 | Feature enhancements will only be merged into minor releases, not into patch releases. 269 | 270 | Team Members and Contributors 271 | ------------------------------ 272 | The following list includes names and aliases for people who had something to do with the creation/maintenance of this library. It takes alot of resources to maintain an Open Source project, thus, we will always do our best to make sure contributions and tested and merged as fast as possible. 273 | 274 | Nir Simionovich, https://github.com/greenfieldtech-nirs 275 | Leonid Notik, https://github.com/lnotik 276 | Scott Griepentrog, https://github.com/stgnet 277 | Matak, https://github.com/matak 278 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "greenfieldtech-nirs/phpari", 3 | "type": "library", 4 | "description": "A PHP Class Library for Asterisk ARI", 5 | "keywords": ["Asterisk", "ARI", "VoIP", "REST", "PHP"], 6 | "homepage": "https://github.com/greenfieldtech-nirs/phpari", 7 | "license": "GPL-2.0", 8 | "authors": [ 9 | { 10 | "name": "Nir Simionovich", 11 | "email": "nir.simionovich@gmail.com", 12 | "homepage": "http://www.simionovich.com", 13 | "role": "Packager" 14 | } 15 | ], 16 | "require": { 17 | "php": ">=7.0.0", 18 | "educoder/pest": "1.0.0", 19 | "devristo/phpws": "dev-master", 20 | "wyrihaximus/react-guzzle": "1.0.0" 21 | }, 22 | "autoload": { 23 | "files": [ 24 | "phpari.php", 25 | "phpari_config.php", 26 | "src/interfaces/asterisk.php", 27 | "src/interfaces/channels.php", 28 | "src/interfaces/bridges.php", 29 | "src/interfaces/endpoints.php", 30 | "src/interfaces/recordings.php", 31 | "src/interfaces/applications.php", 32 | "src/interfaces/devicestates.php", 33 | "src/interfaces/events.php", 34 | "src/interfaces/mailboxes.php", 35 | "src/interfaces/sounds.php", 36 | "src/interfaces/playbacks.php", 37 | "src/helpers/parsing_helper.php", 38 | "src/helpers/config_helper.php" 39 | ] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /contrib/init.d/TODO: -------------------------------------------------------------------------------- 1 | TODO 2 | ---- 3 | Here is a list of things that we need to for part of the package: 4 | 5 | - Init scripts for various distributions 6 | - Icinga/Nagios plugins for monitoring the operation of a Stasis application 7 | - Ideas? 8 | 9 | -------------------------------------------------------------------------------- /contrib/init.d/stasis-centos.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/php -q 2 | /dev/null 2> /dev/null"; 25 | $pidFile = "/var/run/" . $ServiceAlias . ".pid"; 26 | 27 | if (isset($argv[1])) { 28 | switch ($argv[1]) { 29 | case "start": 30 | // Clear the pidFile 31 | exec("rm -f " . $pidFile); 32 | for ($i = 1; $i < $ServiceRunners + 1; $i++) { 33 | $pid = pcntl_fork(); 34 | if ($pid == -1) { 35 | die ("Unable to fork new process"); 36 | } else if ($pid) { 37 | $pid_arr[$i] = $pid; 38 | echo "Starting " . $ServiceAlias . " child number " . $i . " : [OK]\n"; 39 | exit(0); 40 | } else { 41 | $cpid = pcntl_fork(); 42 | if ($cpid == -1) { 43 | die ("Unable to fork new child"); 44 | } 45 | if (!$cpid) { 46 | pcntl_signal(SIGTERM, "sig_handler"); 47 | pcntl_signal(SIGHUP, "sig_handler"); 48 | $childPID = posix_getpid(); 49 | exec("echo " . $childPID . " >> " . $pidFile); 50 | while (1) { 51 | exec($ServiceCmd); 52 | usleep($ServiceSleep . "000"); 53 | } 54 | exit(0); 55 | } 56 | } 57 | } 58 | break; 59 | case "stop": 60 | killChildren(); 61 | break; 62 | case "restart": 63 | hupChildren(); 64 | break; 65 | case "default": 66 | echo "Usage: " . $ServiceAlias . " start|stop|restart\n"; 67 | break; 68 | } 69 | } else { 70 | echo "Usage: " . $ServiceAlias . " start|stop|restart\n"; 71 | } 72 | 73 | 74 | function sig_handler($signo) 75 | { 76 | switch ($signo) { 77 | case SIGTERM: 78 | exit; 79 | break; 80 | case SIGHUP: 81 | foreach ($pid_arr as $kpid) { 82 | posix_kill($kpid, SIGTERM); 83 | $i--; 84 | } 85 | break; 86 | default: 87 | } 88 | } 89 | 90 | function killChildren() 91 | { 92 | global $pidFile; 93 | global $ServiceAlias; 94 | 95 | if (file_exists($pidFile)) { 96 | $pf = fopen($pidFile, "r"); 97 | while ($pid = fgets($pf)) { 98 | exec("kill -9 " . $pid); 99 | echo "Stopping " . $ServiceAlias . " PID " . trim($pid) . ": [OK]\n"; 100 | } 101 | exec("rm -f " . $pidFile); 102 | exit(0); 103 | } else { 104 | echo "PID file missing, most probably the service is stopped!\n"; 105 | exit (99); 106 | } 107 | } 108 | 109 | function hupChildren() 110 | { 111 | global $pidFile; 112 | global $ServiceAlias; 113 | 114 | if (file_exists($pidFile)) { 115 | $pf = fopen($pidFile, "r"); 116 | while ($pid = fgets($pf)) { 117 | exec("kill -1 " . $pid); 118 | } 119 | echo "Restarting " . $ServiceAlias . ": [OK]\n"; 120 | exit(0); 121 | } else { 122 | echo "PID file missing, most probably the service is stopped!\n"; 123 | exit (99); 124 | } 125 | } 126 | 127 | ?> -------------------------------------------------------------------------------- /examples/ApplicationList.php: -------------------------------------------------------------------------------- 1 | applications_list(); 36 | 37 | if ((!$result) && (count($result))) 38 | throw new Exception("phpari error occured", 503); 39 | 40 | print_r ($result); 41 | exit(0); 42 | 43 | } catch (Exception $e) { 44 | echo "Error: " . $conn->lasterror. "\n"; 45 | echo "Trace: " . $conn->lasttrace. "\n"; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /examples/BasicStasisApplication.php: -------------------------------------------------------------------------------- 1 | phpariObject = new phpari($appname); 53 | 54 | $this->ariEndpoint = $this->phpariObject->ariEndpoint; 55 | $this->stasisClient = $this->phpariObject->stasisClient; 56 | $this->stasisLoop = $this->phpariObject->stasisLoop; 57 | $this->stasisLogger = $this->phpariObject->stasisLogger; 58 | $this->stasisEvents = $this->phpariObject->stasisEvents; 59 | } catch (Exception $e) { 60 | echo $e->getMessage(); 61 | exit(99); 62 | } 63 | } 64 | 65 | public function setDtmf($digit = NULL) 66 | { 67 | try { 68 | 69 | $this->dtmfSequence .= $digit; 70 | 71 | return TRUE; 72 | 73 | } catch (Exception $e) { 74 | return FALSE; 75 | } 76 | } 77 | 78 | // process stasis events 79 | public function StasisAppEventHandler() 80 | { 81 | $this->stasisEvents->on('StasisStart', function ($event) { 82 | $this->stasisLogger->notice("Event received: StasisStart"); 83 | $this->stasisChannelID = $event->channel->id; 84 | $this->phpariObject->channels()->channel_answer($this->stasisChannelID); 85 | $this->phpariObject->channels()->channel_playback($this->stasisChannelID, 'sound:demo-thanks', NULL, NULL, NULL, 'play1'); 86 | }); 87 | 88 | $this->stasisEvents->on('StasisEnd', function ($event) { 89 | /* 90 | * The following section will produce an error, as the channel no longer exists in this state - this is intentional 91 | */ 92 | $this->stasisLogger->notice("Event received: StasisEnd"); 93 | if (!$this->phpariObject->channels()->channel_delete($this->stasisChannelID)) 94 | $this->stasisLogger->notice("Error occurred: " . $this->phpariObject->lasterror); 95 | }); 96 | 97 | 98 | $this->stasisEvents->on('PlaybackStarted', function ($event) { 99 | $this->stasisLogger->notice("+++ PlaybackStarted +++ " . json_encode($event->playback) . "\n"); 100 | }); 101 | 102 | $this->stasisEvents->on('PlaybackFinished', function ($event) { 103 | switch ($event->playback->id) { 104 | case "play1": 105 | $this->phpariObject->channels()->channel_playback($this->stasisChannelID, 'sound:demo-congrats', NULL, NULL, NULL, 'play2'); 106 | break; 107 | case "play2": 108 | $this->phpariObject->channels()->channel_playback($this->stasisChannelID, 'sound:demo-echotest', NULL, NULL, NULL, 'end'); 109 | break; 110 | case "end": 111 | $this->phpariObject->channels()->channel_continue($this->stasisChannelID); 112 | break; 113 | } 114 | }); 115 | 116 | $this->stasisEvents->on('ChannelDtmfReceived', function ($event) { 117 | $this->setDtmf($event->digit); 118 | $this->stasisLogger->notice("+++ DTMF Received +++ [" . $event->digit . "] [" . $this->dtmfSequence . "]\n"); 119 | switch ($event->digit) { 120 | case "*": 121 | $this->dtmfSequence = ""; 122 | $this->stasisLogger->notice("+++ Resetting DTMF buffer\n"); 123 | break; 124 | case "#": 125 | $this->stasisLogger->notice("+++ Playback ID: " . $this->phpariObject->playbacks()->get_playback()); 126 | $this->phpariObject->channels()->channel_continue($this->stasisChannelID, "demo", "s", 1); 127 | break; 128 | default: 129 | break; 130 | } 131 | }); 132 | } 133 | 134 | public function StasisAppConnectionHandlers() 135 | { 136 | try { 137 | $this->stasisClient->on("request", function ($headers) { 138 | $this->stasisLogger->notice("Request received!"); 139 | }); 140 | 141 | $this->stasisClient->on("handshake", function () { 142 | $this->stasisLogger->notice("Handshake received!"); 143 | }); 144 | 145 | $this->stasisClient->on("message", function ($message) { 146 | $event = json_decode($message->getData()); 147 | $this->stasisLogger->notice('Received event: ' . $event->type); 148 | $this->stasisEvents->emit($event->type, array($event)); 149 | }); 150 | 151 | } catch (Exception $e) { 152 | echo $e->getMessage(); 153 | exit(99); 154 | } 155 | } 156 | 157 | public function execute() 158 | { 159 | try { 160 | $this->stasisClient->open(); 161 | $this->stasisLoop->run(); 162 | } catch (Exception $e) { 163 | echo $e->getMessage(); 164 | exit(99); 165 | } 166 | } 167 | 168 | } 169 | 170 | $basicAriClient = new BasicStasisApplication("hello-world"); 171 | 172 | $basicAriClient->stasisLogger->info("Starting Stasis Program... Waiting for handshake..."); 173 | $basicAriClient->StasisAppEventHandler(); 174 | 175 | $basicAriClient->stasisLogger->info("Initializing Handlers... Waiting for handshake..."); 176 | $basicAriClient->StasisAppConnectionHandlers(); 177 | 178 | $basicAriClient->stasisLogger->info("Connecting... Waiting for handshake..."); 179 | $basicAriClient->execute(); 180 | 181 | exit(0); -------------------------------------------------------------------------------- /examples/BridgesList.php: -------------------------------------------------------------------------------- 1 | channel_list()); 33 | -------------------------------------------------------------------------------- /examples/ChannelDelete.php: -------------------------------------------------------------------------------- 1 | postData, FALSE); 39 | $channelID = $postDataObject->channelID; 40 | $response = $channels->channel_delete($channelID); 41 | 42 | echo json_encode($response); 43 | exit(0); 44 | 45 | 46 | } catch (Exception $e) { 47 | echo json_encode(array('status' => $e->getCode(), 'message' => $e->getMessage())); 48 | } 49 | 50 | ?> -------------------------------------------------------------------------------- /examples/ChannelOriginate.php: -------------------------------------------------------------------------------- 1 | channel_originate( 32 | 'SIP/7001', 33 | NULL, 34 | array( 35 | "extension" => "7001", 36 | "context" => 'from-phone', 37 | "priority" => 1, 38 | "app" => "", 39 | "appArgs" => "", 40 | "callerId" => "111", 41 | "timeout" => -1, 42 | "channelId" => '324234', 43 | "otherChannelId" => "" 44 | ), 45 | array("var1" => "cool") 46 | ); 47 | 48 | echo json_encode($response); 49 | exit(0); 50 | 51 | ?> -------------------------------------------------------------------------------- /examples/ChannelsList.php: -------------------------------------------------------------------------------- 1 | channel_list()); 33 | 34 | ?> -------------------------------------------------------------------------------- /examples/DeviceStatesList.php: -------------------------------------------------------------------------------- 1 | devicestates_list()); 33 | 34 | 35 | exit(0); -------------------------------------------------------------------------------- /examples/EndPointList.php: -------------------------------------------------------------------------------- 1 | endpoints_list(); 32 | 33 | echo json_encode($response); 34 | exit(0); 35 | 36 | 37 | ?> -------------------------------------------------------------------------------- /examples/EventGenerateExample.php: -------------------------------------------------------------------------------- 1 | "cool"); 34 | $response = $event->event_generate('justName', "hello-world", "141", NULL, 'SIP/7008', "leosip", $valiables); 35 | 36 | echo json_encode($response); 37 | exit(0); 38 | } catch (Exception $e) { 39 | echo json_encode(array('status' => $e->getCode(), 'message' => $e->getMessage())); 40 | } 41 | 42 | 43 | ?> -------------------------------------------------------------------------------- /examples/EventsForApp.php: -------------------------------------------------------------------------------- 1 | events('hello-world')); 33 | exit(0); 34 | ?> -------------------------------------------------------------------------------- /examples/EventsForAppStasis.php: -------------------------------------------------------------------------------- 1 | conn = new phpari("hello-world"); //create new object 38 | $this->events = new events($this->conn); 39 | 40 | 41 | } 42 | 43 | public function handlers() 44 | { 45 | try { 46 | $this->conn->stasisClient->on("request", function ($headers) { 47 | $this->conn->stasisLogger->notice("Request received!"); 48 | }); 49 | 50 | $this->conn->stasisClient->on("handshake", function () { 51 | $this->conn->stasisLogger->notice("Handshake received!"); 52 | }); 53 | 54 | $this->conn->stasisClient->on("message", function ($message) { 55 | 56 | 57 | $this->stasisLogger->notice(json_encode($message)); 58 | $this->stasisLogger->notice($this->events->events('hello-world')); 59 | }); 60 | 61 | } catch (Exception $e) { 62 | echo $e->getMessage(); 63 | exit(99); 64 | } 65 | } 66 | 67 | public function execute() 68 | { 69 | try { 70 | $this->conn->stasisClient->open(); 71 | $this->conn->stasisLoop->run(); 72 | 73 | } catch (Exception $e) { 74 | echo $e->getMessage(); 75 | exit(99); 76 | } 77 | } 78 | 79 | } 80 | 81 | $eventForApp = new EventsForAppStasis(); 82 | $eventForApp->handlers(); 83 | $eventForApp->execute(); 84 | 85 | exit(0); -------------------------------------------------------------------------------- /examples/MailBoxCreate.php: -------------------------------------------------------------------------------- 1 | mailbox_change_state('testMailBox', 0, 0)); 33 | exit(0); 34 | ?> -------------------------------------------------------------------------------- /examples/MailBoxesList.php: -------------------------------------------------------------------------------- 1 | mailboxes_list()); 33 | exit(0); 34 | ?> -------------------------------------------------------------------------------- /examples/RecordingList.php: -------------------------------------------------------------------------------- 1 | recording_list()); 33 | exit(0); 34 | ?> -------------------------------------------------------------------------------- /examples/SoundsList.php: -------------------------------------------------------------------------------- 1 | sounds_list('en', 'gsm')); 33 | exit(0); 34 | ?> -------------------------------------------------------------------------------- /examples/StasisAppDial.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/php -q 2 | 3 | phpariObject = new phpari($appname, 'phpari.ini'); 55 | 56 | $this->ariEndpoint = $this->phpariObject->ariEndpoint; 57 | $this->stasisClient = $this->phpariObject->stasisClient; 58 | $this->stasisLoop = $this->phpariObject->stasisLoop; 59 | $this->stasisLogger = $this->phpariObject->stasisLogger; 60 | $this->stasisEvents = $this->phpariObject->stasisEvents; 61 | 62 | } catch (Exception $e) { 63 | echo $e->getMessage(); 64 | exit(99); 65 | } 66 | } 67 | 68 | public function setDtmf($digit = NULL) 69 | { 70 | try { 71 | 72 | $this->dtmfSequence .= $digit; 73 | 74 | return TRUE; 75 | 76 | } catch (Exception $e) { 77 | return FALSE; 78 | } 79 | } 80 | 81 | // process stasis events 82 | public function StasisAppEventHandler() 83 | { 84 | $this->stasisEvents->on('StasisStart', function ($event) { 85 | 86 | $this->stasisLogger->notice("Event received: StasisStart"); 87 | 88 | $args = $event->args; 89 | if (isset($args[0])) { 90 | $this->stasisChannelID = $event->channel->id; 91 | $this->stasisLogger->notice("Creating new instance in channelStorage"); 92 | $this->stasisLogger->notice("channelStorage: " . print_r($this->channelStorage, TRUE)); 93 | $this->stasisLogger->notice("About to originate a call to another party, and bridge to us"); 94 | $response = $this->phpariObject->channels()->channel_originate( 95 | $args[0], 96 | NULL, 97 | array( 98 | "app" => "stasis-dial", 99 | "appArgs" => '', 100 | "timeout" => $args[1] 101 | ) 102 | ); 103 | 104 | /* Creating a Bridge resource */ 105 | $this->phpariObject->bridges()->create('mixing', 'bridge_' . $response['id']); 106 | 107 | /* Populate the Storage */ 108 | $this->channelStorage[$response['id']]['epoch'] = time(); 109 | $this->channelStorage[$response['id']]['bridge'] = "bridge_" . $response['id']; 110 | $this->channelStorage[$response['id']]['A'] = $event->channel->id; 111 | $this->channelStorage[$response['id']]['B'] = $response['id']; 112 | $this->channelStorage[$event->channel->id]['bridge'] = "bridge_" . $response['id']; 113 | $this->channelStorage[$event->channel->id]['B'] = $event->channel->id; 114 | $this->channelStorage[$event->channel->id]['A'] = $response['id']; 115 | 116 | /* Join the bridge */ 117 | $this->phpariObject->channels()->channel_ringing_start($event->channel->id); 118 | 119 | } else { 120 | $this->stasisLogger->notice("First channel is joinging the bridge: " . $event->channel->id . " -> bridge_" . $response['id']); 121 | $this->phpariObject->channels()->channel_ringing_stop($this->channelStorage[$event->channel->id]['A']); 122 | $this->phpariObject->channels()->channel_answer($this->channelStorage[$event->channel->id]['A']); 123 | $this->phpariObject->bridges()->addchannel($this->channelStorage[$event->channel->id]['bridge'], $this->channelStorage[$event->channel->id]['A']); 124 | $this->stasisLogger->notice("Second channel is joining the bridge: " . $event->channel->id . " -> bridge_" . $event->channel->id); 125 | $this->phpariObject->channels()->channel_answer($event->channel->id); 126 | $this->phpariObject->bridges()->addchannel($this->channelStorage[$event->channel->id]['bridge'], $event->channel->id); 127 | } 128 | }); 129 | 130 | $this->stasisEvents->on('StasisEnd', function ($event) { 131 | /* 132 | * The following section will produce an error, as the channel no longer exists in this state - this is intentional 133 | */ 134 | $this->stasisLogger->notice("Event received: StasisEnd"); 135 | if (isset($this->channelStorage[$event->channel->id])) { 136 | $this->stasisLogger->notice("channelStorage: " . print_r($this->channelStorage, TRUE)); 137 | 138 | $this->stasisLogger->notice("Terminating: " . $event->channel->id); 139 | $this->phpariObject->channels()->channel_delete($event->channel->id); 140 | 141 | $this->stasisLogger->notice("Terminating: " . $this->channelStorage[$event->channel->id]['A']); 142 | $this->phpariObject->channels()->channel_delete($this->channelStorage[$event->channel->id]['A']); 143 | 144 | $this->stasisLogger->notice("Terminating: " . $this->channelStorage[$event->channel->id]['bridge']); 145 | $this->phpariObject->bridges()->terminate($this->channelStorage[$event->channel->id]['bridge']); 146 | 147 | unset($this->channelStorage[$this->channelStorage[$event->channel->id]['A']]); 148 | unset($this->channelStorage[$event->channel->id]); 149 | $this->stasisLogger->notice("channelStorage: " . print_r($this->channelStorage, TRUE)); 150 | } 151 | }); 152 | } 153 | 154 | public function StasisAppConnectionHandlers() 155 | { 156 | try { 157 | $this->stasisClient->on("request", function ($headers) { 158 | $this->stasisLogger->notice("Request received!"); 159 | }); 160 | 161 | $this->stasisClient->on("handshake", function () { 162 | $this->stasisLogger->notice("Handshake received!"); 163 | }); 164 | 165 | $this->stasisClient->on("message", function ($message) { 166 | $this->stasisLogger->notice("channelStorage: " . print_r($this->channelStorage, TRUE)); 167 | $event = json_decode($message->getData()); 168 | $this->stasisLogger->notice('Received event: ' . $event->type); 169 | $this->stasisEvents->emit($event->type, array($event)); 170 | }); 171 | 172 | } catch (Exception $e) { 173 | echo $e->getMessage(); 174 | exit(99); 175 | } 176 | } 177 | 178 | public function execute() 179 | { 180 | try { 181 | $this->stasisClient->open(); 182 | $this->stasisLoop->run(); 183 | } catch (Exception $e) { 184 | echo $e->getMessage(); 185 | exit(99); 186 | } 187 | } 188 | 189 | } 190 | 191 | $basicAriClient = new Dial("stasis-dial"); 192 | 193 | $basicAriClient->stasisLogger->info("Starting Stasis Program... Waiting for handshake..."); 194 | $basicAriClient->StasisAppEventHandler(); 195 | 196 | $basicAriClient->stasisLogger->info("Initializing Handlers... Waiting for handshake..."); 197 | $basicAriClient->StasisAppConnectionHandlers(); 198 | 199 | $basicAriClient->stasisLogger->info("Connecting... Waiting for handshake..."); 200 | $basicAriClient->execute(); 201 | 202 | exit(0); -------------------------------------------------------------------------------- /phpari.ini.sample: -------------------------------------------------------------------------------- 1 | [general] 2 | debug=0 3 | logfile=console ; console for direct console output, filename for file based logging 4 | 5 | [asterisk_ari] 6 | username=asterisk 7 | password=asterisk 8 | host=127.0.0.1 9 | port=8088 10 | protocol=http 11 | endpoint=/ari 12 | transport=ws ; ws for none encrypted, wss for encrypted (currently, only ws is supported) 13 | 14 | [asterisk_manager] 15 | username=amiuser 16 | password=amipassword 17 | host=127.0.0.1 18 | port=5038 19 | 20 | -------------------------------------------------------------------------------- /phpari.php: -------------------------------------------------------------------------------- 1 | configuration = new phpari_config($config); 89 | 90 | /* Some general information */ 91 | $this->debug = $this->configuration->general['debug']; 92 | $this->logfile = $this->configuration->general['logfile']; 93 | 94 | /* Connect to ARI server */ 95 | $result = $this->connect($this->configuration->asterisk_ari['username'], 96 | $this->configuration->asterisk_ari['password'], 97 | $stasisApplication, 98 | $this->configuration->asterisk_ari['host'], 99 | $this->configuration->asterisk_ari['port'], 100 | $this->configuration->asterisk_ari['endpoint'], 101 | $this->configuration->asterisk_ari['transport'], 102 | $this->configuration->asterisk_ari['protocol']); 103 | 104 | return $result; 105 | 106 | 107 | } catch (Exception $e) { 108 | die("Exception raised: " . $e->getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 109 | } 110 | 111 | } 112 | 113 | /** 114 | * This function is connecting and returning a phpari client object which 115 | * transferred to any of the interfaces will assist with the connection process 116 | * to the Asterisk Stasis or to the Asterisk 12 web server (Channels list , End Points list) 117 | * etc. 118 | * 119 | * @param $ariUsername 120 | * @param $ariPassword 121 | * @param $stasisApplication 122 | * @param $ariServer 123 | * @param $ariPort 124 | * @param $ariEndpoint 125 | * @param $ariTransport 126 | * 127 | * @return array 128 | */ 129 | private function connect($ariUsername, $ariPassword, $stasisApplication, $ariServer, $ariPort, $ariEndpoint, $ariTransport, $ariProtocol = "http") 130 | { 131 | 132 | try { 133 | 134 | $this->ariEndpoint = new PestJSON("http://" . $ariServer . ":" . $ariPort . $ariEndpoint); 135 | $this->ariEndpoint->setupAuth($ariUsername, $ariPassword, "basic"); 136 | 137 | /* Create eventloop */ 138 | $this->ariEndpointURL = $ariProtocol . "://" . $ariServer . ":" . $ariPort . $ariEndpoint; 139 | $this->ariUsername = $ariUsername; 140 | $this->ariPassword = $ariPassword; 141 | 142 | $this->stasisLoop = \React\EventLoop\Factory::create(); 143 | 144 | $this->stasisLogger = new \Zend\Log\Logger(); 145 | 146 | if ($this->configuration->general['logfile'] == "console") { 147 | $logWriter = new Zend\Log\Writer\Stream("php://output"); 148 | } else { 149 | $logWriter = new Zend\Log\Writer\Stream($this->configuration->general['logfile']); 150 | } 151 | 152 | $this->stasisLogger->addWriter($logWriter); 153 | 154 | if ($this->debug) $this->stasisLogger->debug("Initializing WebSocket Information"); 155 | 156 | $this->stasisClient = new \Devristo\Phpws\Client\WebSocket($ariTransport . "://" . $ariServer . ":" . $ariPort . $ariEndpoint . "/events?api_key=" . $ariUsername . ":" . $ariPassword . "&app=" . $stasisApplication, $this->stasisLoop, $this->stasisLogger); 157 | 158 | if ($this->debug) $this->stasisLogger->debug("Initializing Stasis Event Emitter"); 159 | 160 | $this->stasisEvents = new Evenement\EventEmitter(); 161 | 162 | 163 | return TRUE; 164 | //return array("stasisClient" => $this->stasisClient, "stasisLoop" => $this->stasisLoop, "stasisLogger" => $this->stasisLogger, "ariEndpoint" => $this->ariEndpoint); 165 | 166 | } catch (Exception $e) { 167 | die("Exception raised: " . $e->getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 168 | } 169 | } 170 | 171 | /** 172 | * @return applications|bool - An applications object, or FALSE on failure 173 | */ 174 | public function applications() 175 | { 176 | try { 177 | if (!isset($this->applications)) { 178 | $this->applications = new applications($this); 179 | if ($this->debug) $this->stasisLogger->debug("applications class had been initiated"); 180 | } 181 | 182 | return $this->applications; 183 | } catch (Exception $e) { 184 | if ($this->debug) $this->stasisLogger->debug("applications has failed initialization"); 185 | $this->lasterror = "applications class failed to initialize properly"; 186 | 187 | return FALSE; 188 | } 189 | } 190 | 191 | /** 192 | * @return asterisk|bool - An asterisk object, or FALSE on failure 193 | */ 194 | public function asterisk() 195 | { 196 | try { 197 | if (!isset($this->asterisk)) { 198 | $this->asterisk = new asterisk($this); 199 | if ($this->debug) $this->stasisLogger->debug("asterisk class had been initiated"); 200 | } 201 | 202 | return $this->asterisk; 203 | } catch (Exception $e) { 204 | if ($this->debug) $this->stasisLogger->debug("asterisk has failed initialization"); 205 | $this->lasterror = "asterisk class failed to initialize properly"; 206 | 207 | return FALSE; 208 | } 209 | } 210 | 211 | /** 212 | * @return bridges|bool - An bridges object, or FALSE on failure 213 | */ 214 | public function bridges() 215 | { 216 | try { 217 | if (!isset($this->bridges)) { 218 | $this->bridges = new bridges($this); 219 | if ($this->debug) $this->stasisLogger->debug("bridges class had been initiated"); 220 | } 221 | 222 | return $this->bridges; 223 | } catch (Exception $e) { 224 | if ($this->debug) $this->stasisLogger->debug("bridges has failed initialization"); 225 | $this->lasterror = "bridges class failed to initialize properly"; 226 | 227 | return FALSE; 228 | } 229 | } 230 | 231 | /** 232 | * @return channels|bool - An channels object, or FALSE on failure 233 | */ 234 | public function channels() 235 | { 236 | try { 237 | if (!isset($this->channels)) { 238 | $this->channels = new channels($this); 239 | if ($this->debug) $this->stasisLogger->debug("channels class had been initiated"); 240 | } 241 | 242 | return $this->channels; 243 | } catch (Exception $e) { 244 | if ($this->debug) $this->stasisLogger->debug("channels has failed initialization"); 245 | $this->lasterror = "channels class failed to initialize properly"; 246 | 247 | return FALSE; 248 | } 249 | } 250 | 251 | /** 252 | * @return devicestates|bool - An devicestates object, or FALSE on failure 253 | */ 254 | public function devicestates() 255 | { 256 | try { 257 | if (!isset($this->devicestates)) { 258 | $this->devicestates = new devicestates($this); 259 | if ($this->debug) $this->stasisLogger->debug("devicestates class had been initiated"); 260 | } 261 | 262 | return $this->devicestates; 263 | } catch (Exception $e) { 264 | if ($this->debug) $this->stasisLogger->debug("devicestates has failed initialization"); 265 | $this->lasterror = "devicestates class failed to initialize properly"; 266 | 267 | return FALSE; 268 | } 269 | } 270 | 271 | /** 272 | * @return endpoints|bool - An endpoints object, or FALSE on failure 273 | */ 274 | public function endpoints() 275 | { 276 | try { 277 | if (!isset($this->endpoints)) { 278 | $this->endpoints = new endpoints($this); 279 | if ($this->debug) $this->stasisLogger->debug("endpoints class had been initiated"); 280 | } 281 | 282 | return $this->endpoints; 283 | } catch (Exception $e) { 284 | if ($this->debug) $this->stasisLogger->debug("endpoints has failed initialization"); 285 | $this->lasterror = "endpoints class failed to initialize properly"; 286 | 287 | return FALSE; 288 | } 289 | } 290 | 291 | /** 292 | * @return events|bool - An events object, or FALSE on failure 293 | */ 294 | public function events() 295 | { 296 | try { 297 | if (!isset($this->events)) { 298 | $this->events = new events($this); 299 | if ($this->debug) $this->stasisLogger->debug("events class had been initiated"); 300 | } 301 | 302 | return $this->events; 303 | } catch (Exception $e) { 304 | if ($this->debug) $this->stasisLogger->debug("events has failed initialization"); 305 | $this->lasterror = "events class failed to initialize properly"; 306 | 307 | return FALSE; 308 | } 309 | } 310 | 311 | /** 312 | * @return mailboxes|bool - An mailboxes object, or FALSE on failure 313 | */ 314 | public function mailboxes() 315 | { 316 | try { 317 | if (!isset($this->mailboxes)) { 318 | $this->mailboxes = new mailboxes($this); 319 | if ($this->debug) $this->stasisLogger->debug("mailboxes class had been initiated"); 320 | } 321 | 322 | return $this->mailboxes; 323 | } catch (Exception $e) { 324 | if ($this->debug) $this->stasisLogger->debug("mailboxes has failed initialization"); 325 | $this->lasterror = "mailboxes class failed to initialize properly"; 326 | 327 | return FALSE; 328 | } 329 | } 330 | 331 | /** 332 | * @return recordings|bool - An recordings object, or FALSE on failure 333 | */ 334 | public function recordings() 335 | { 336 | try { 337 | if (!isset($this->recordings)) { 338 | $this->recordings = new recordings($this); 339 | if ($this->debug) $this->stasisLogger->debug("recordings class had been initiated"); 340 | } 341 | 342 | return $this->recordings; 343 | } catch (Exception $e) { 344 | if ($this->debug) $this->stasisLogger->debug("recordings has failed initialization"); 345 | $this->lasterror = "recordings class failed to initialize properly"; 346 | 347 | return FALSE; 348 | } 349 | } 350 | 351 | /** 352 | * @return sounds|bool - An sounds object, or FALSE on failure 353 | */ 354 | public function sounds() 355 | { 356 | try { 357 | if (!isset($this->sounds)) { 358 | $this->sounds = new sounds($this); 359 | if ($this->debug) $this->stasisLogger->debug("sounds class had been initiated"); 360 | } 361 | 362 | return $this->sounds; 363 | } catch (Exception $e) { 364 | if ($this->debug) $this->stasisLogger->debug("sounds has failed initialization"); 365 | $this->lasterror = "sounds class failed to initialize properly"; 366 | 367 | return FALSE; 368 | } 369 | } 370 | 371 | /** 372 | * @return playbacks|bool - An playbacks object, or FALSE on failure 373 | */ 374 | public function playbacks() 375 | { 376 | try { 377 | if (!isset($this->playbacks)) { 378 | $this->playbacks = new playbacks($this); 379 | if ($this->debug) $this->stasisLogger->debug("playbacks class had been initiated"); 380 | } 381 | 382 | return $this->playbacks; 383 | } catch (Exception $e) { 384 | if ($this->debug) $this->stasisLogger->debug("playbacks has failed initialization"); 385 | $this->lasterror = "playbacks class failed to initialize properly"; 386 | 387 | return FALSE; 388 | } 389 | } 390 | 391 | } 392 | -------------------------------------------------------------------------------- /phpari_config.php: -------------------------------------------------------------------------------- 1 | array( 30 | 'logfile' => 'console', 31 | 'debug' => 0, 32 | ), 33 | 'asterisk_ari' => array( 34 | 'username' => 'asterisk', 35 | 'password' => 'asterisk', 36 | 'host' => '127.0.0.1', 37 | 'port' => '8088', 38 | 'endpoint' => '/ari', 39 | 'transport' => 'ws', 40 | 'protocol' => 'http' 41 | ), 42 | 'asterisk_manager' => array( 43 | 'username' => 'amiuser', 44 | 'password' => 'amipassword', 45 | 'host' => '127.0.0.1', 46 | 'port' => '5038' 47 | ), 48 | ); 49 | 50 | public function __construct($config = 'phpari.ini') { 51 | if (is_array($config)) { 52 | $this->config_merge($config); 53 | return; 54 | } 55 | 56 | // in case we read a fle for initialization, its easy 57 | if (($ini = parse_ini_file($config, TRUE)) === false) 58 | throw new Exception("Invald INI file provided: '$config'"); 59 | $this->config_merge($ini); 60 | } 61 | 62 | private function config_merge($config = []) { 63 | foreach ($config as $section => $settings) { 64 | if (array_key_exists($section, $this->configuration)) 65 | $this->configuration[$section] = array_merge($this->configuration[$section], $config[$section]); 66 | else 67 | $this->configuration[$section] = $config[$section]; 68 | } 69 | } 70 | 71 | public function __get($section) { 72 | return @$this->configuration[$section]; 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/helpers/config_helper.php: -------------------------------------------------------------------------------- 1 | getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 38 | } 39 | } 40 | 41 | function getconfig($stasisObject = NULL, $configitem = NULL) 42 | { 43 | try { 44 | if ($stasisObject == NULL) 45 | throw new Exception("stasisObject not provided", 503); 46 | 47 | return FALSE; 48 | } catch (Exception $e) { 49 | return false; 50 | } 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /src/helpers/parsing_helper.php: -------------------------------------------------------------------------------- 1 | getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 37 | } 38 | } 39 | 40 | /** 41 | * Ascertain if the input provided by $rawInput is one of the following: JSON_STRING, JSON_OBJECT, ASSOC_ARRAY. 42 | * The return value shall always be an ASSOC_ARRAY, represting $rawInput in a unified manner 43 | * 44 | * @param null $rawInput 45 | * 46 | * @return mixed 47 | */ 48 | function parseRequestData($rawInput = NULL) 49 | { 50 | try { 51 | 52 | if ($rawInput == NULL) 53 | throw new Exception ("Input must be defined", 503); 54 | 55 | $result = array(); 56 | 57 | if (is_string($rawInput)) 58 | $result = json_decode($rawInput, TRUE); 59 | 60 | if (is_array($rawInput)) 61 | $result = $rawInput; 62 | 63 | if (is_object($rawInput)) 64 | $result = json_decode(json_encode($rawInput), TRUE); 65 | 66 | return $result; 67 | 68 | } catch (Exception $e) { 69 | die("Exception raised: " . $e->getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 70 | } 71 | } 72 | 73 | /** 74 | * Ascertain if the input is an associative array or not. 75 | * This test is far from being perfect - still needs sanity checks and better resolution 76 | * 77 | * @param $arr 78 | * 79 | * @return bool 80 | */ 81 | function isAssoc($arr) 82 | { 83 | return array_keys($arr) !== range(0, count($arr) - 1); 84 | } 85 | 86 | } -------------------------------------------------------------------------------- /src/interfaces/applications.php: -------------------------------------------------------------------------------- 1 | ariEndpointURL)) 41 | throw new Exception("Missing endpoint or empty string", 503); 42 | 43 | $this->phpariObject = $connObject; 44 | 45 | $this->ariEndpointURL = $connObject->ariEndpointURL; 46 | 47 | $this->ariEndpointClient = new Client([ 48 | 'base_uri' => $this->ariEndpointURL, 49 | 'timeout' => 2.0 50 | ]); 51 | 52 | $this->ariEndpointOptions = [ 53 | 'debug' => false, 54 | 'auth' => [ 55 | $connObject->ariUsername, 56 | $connObject->ariPassword 57 | ] 58 | ]; 59 | 60 | } catch (Exception $e) { 61 | die("Exception raised: " . $e->getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 62 | } 63 | } 64 | 65 | private function validate_event_sources($eventSources = null) 66 | { 67 | 68 | $eventsList = explode(",", $eventSources); 69 | 70 | foreach ($eventsList as $eventURI) { 71 | $eventSourceType = strtok($eventURI, ":"); 72 | 73 | switch ($eventSourceType) { 74 | case "channel": 75 | case "bridge": 76 | case "endpoint": 77 | case "deviceState": 78 | break; 79 | default: 80 | throw new Exception("Unknown event type for URI " . $eventURI, 503); 81 | break; 82 | } 83 | } 84 | 85 | return 0; 86 | 87 | } 88 | 89 | /** 90 | * GET List of all applications or information regarding a specific application name 91 | * 92 | * @param null $applicationName 93 | * 94 | * @return mixed 95 | */ 96 | public function show($applicationName = NULL) 97 | { 98 | try { 99 | 100 | $uri = "/applications"; 101 | $uri .= (!is_null($applicationName)) ? "/" . $applicationName : ""; 102 | 103 | $response = $this->ariEndpointClient->get($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents(); 104 | 105 | return json_decode($response); 106 | 107 | } catch (\GuzzleHttp\Exception\RequestException $e) { 108 | $this->phpariObject->lasterror = $e->getMessage(); 109 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 110 | return (int)$e->getCode(); 111 | } catch (\GuzzleHttp\Exception\ClientException $e) { 112 | $this->phpariObject->lasterror = $e->getMessage(); 113 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 114 | return (int)$e->getCode(); 115 | } catch (\GuzzleHttp\Exception\ServerException $e) { 116 | $this->phpariObject->lasterror = $e->getMessage(); 117 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 118 | return (int)$e->getCode(); 119 | } catch (Exception $e) { 120 | 121 | $this->phpariObject->lasterror = $e->getMessage(); 122 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 123 | 124 | return FALSE; 125 | } 126 | } 127 | 128 | /** 129 | * @return mixed 130 | * 131 | * This is just an alias - if you are using this, please stop - it will be deprecated! 132 | */ 133 | public function applications_list() 134 | { 135 | return $this->show(); 136 | } 137 | 138 | /** 139 | * @return mixed 140 | * 141 | * This is just an alias - if you are using this, please stop - it will be deprecated! 142 | */ 143 | public function application_details($applicationName = NULL) 144 | { 145 | return $this->show($applicationName); 146 | } 147 | 148 | /** 149 | * Subscribe an application to a event source. Returns the state of the application after the subscriptions have changed 150 | * 151 | * @param string $applicationName 152 | * @param string $eventSources 153 | * 154 | * @return mixed 155 | */ 156 | public function subscribe($applicationName = NULL, $eventSources = NULL) 157 | { 158 | try { 159 | 160 | if (is_null($applicationName)) 161 | throw new Exception("Application name not provided or is null", 503); 162 | if (is_null($eventSources)) 163 | throw new Exception("eventSources not provided or is null", 503); 164 | 165 | $this->validate_event_sources($eventSources); 166 | 167 | $postObjParams = array( 168 | 'eventSource' => $eventSources 169 | ); 170 | 171 | $uri = "/applications/" . $applicationName . "/subscription"; 172 | $this->ariEndpointOptions['json'] = $postObjParams; 173 | 174 | $result = json_decode($this->ariEndpointClient->post($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 175 | 176 | return $result; 177 | 178 | } catch (\GuzzleHttp\Exception\RequestException $e) { 179 | $this->phpariObject->lasterror = $e->getMessage(); 180 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 181 | return (int)$e->getCode(); 182 | } catch (\GuzzleHttp\Exception\ClientException $e) { 183 | $this->phpariObject->lasterror = $e->getMessage(); 184 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 185 | return (int)$e->getCode(); 186 | } catch (\GuzzleHttp\Exception\ServerException $e) { 187 | $this->phpariObject->lasterror = $e->getMessage(); 188 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 189 | return (int)$e->getCode(); 190 | } catch (Exception $e) { 191 | $this->phpariObject->lasterror = $e->getMessage(); 192 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 193 | return FALSE; 194 | } 195 | 196 | } 197 | 198 | /** 199 | * @param null $applicationName 200 | * @param null $eventSourceURI 201 | * @return mixed 202 | * 203 | * This is just an alias - if you are using this, please stop - it will be deprecated! 204 | */ 205 | public function application_subscribe($applicationName = NULL, $eventSourceURI = NULL) 206 | { 207 | return $this->subscribe($applicationName, $eventSourceURI); 208 | } 209 | 210 | /** 211 | * DELETE Unsubscribe an application from an event source. Returns the state of the application after the subscriptions have changed 212 | * 213 | * @param string $applicationName 214 | * @param string $eventSources 215 | * 216 | * @return mixed 217 | */ 218 | public function unsubscribe($applicationName = NULL, $eventSources = NULL) 219 | { 220 | try { 221 | 222 | if (is_null($applicationName)) 223 | throw new Exception("Application name not provided or is null", 503); 224 | if (is_null($eventSources)) 225 | throw new Exception("eventSources not provided or is null", 503); 226 | 227 | $this->validate_event_sources($eventSources); 228 | 229 | $postObjParams = array( 230 | 'eventSource' => $eventSources 231 | ); 232 | 233 | $uri = "/applications/" . $applicationName . "/subscription"; 234 | 235 | $this->ariEndpointOptions['json'] = $postObjParams; 236 | 237 | $result = json_decode($this->ariEndpointClient->delete($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 238 | 239 | 240 | return $result; 241 | 242 | } catch (\GuzzleHttp\Exception\RequestException $e) { 243 | $this->phpariObject->lasterror = $e->getMessage(); 244 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 245 | return (int)$e->getCode(); 246 | } catch (\GuzzleHttp\Exception\ClientException $e) { 247 | $this->phpariObject->lasterror = $e->getMessage(); 248 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 249 | return (int)$e->getCode(); 250 | } catch (\GuzzleHttp\Exception\ServerException $e) { 251 | $this->phpariObject->lasterror = $e->getMessage(); 252 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 253 | return (int)$e->getCode(); 254 | } catch (Exception $e) { 255 | $this->phpariObject->lasterror = $e->getMessage(); 256 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 257 | 258 | return FALSE; 259 | } 260 | 261 | } 262 | 263 | /** 264 | * @param null $applicationName 265 | * @param null $eventSources 266 | * @return mixed 267 | * 268 | * This is just an alias - if you are using this, please stop - it will be deprecated! 269 | */ 270 | public function application_unsubscribe($applicationName = NULL, $eventSources = NULL) 271 | { 272 | return $this->unsubscribe($applicationName, $eventSources); 273 | } 274 | 275 | } 276 | 277 | 278 | 279 | 280 | 281 | -------------------------------------------------------------------------------- /src/interfaces/asterisk.php: -------------------------------------------------------------------------------- 1 | ariEndpoint)) 36 | throw new Exception("Missing PestObject or empty string", 503); 37 | 38 | $this->phpariObject = $connObject; 39 | 40 | } catch (Exception $e) { 41 | die("Exception raised: " . $e->getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 42 | } 43 | } 44 | 45 | /** 46 | * This function is an alias to 'info' - will be deprecated in phpari 2.0 47 | * 48 | * @param null $filter 49 | * 50 | * @return mixed 51 | */ 52 | public function get_asterisk_info($filter = NULL) 53 | { 54 | return info($filter); 55 | } 56 | 57 | /** 58 | * @param null $filter 59 | * 60 | * @return mixed 61 | */ 62 | public function info($filter = NULL) 63 | { 64 | 65 | try { 66 | 67 | $result = FALSE; 68 | 69 | switch ($filter) { 70 | case "build": 71 | case "system": 72 | case "config": 73 | case "status": 74 | break; 75 | default: 76 | $filter = NULL; 77 | break; 78 | } 79 | 80 | $uri = "/asterisk/info"; 81 | $uri .= (!is_null($filter)) ? '?only=' . $filter : ''; 82 | 83 | $result = json_decode($this->ariEndpointClient->get($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 84 | 85 | return $result; 86 | 87 | } catch (\GuzzleHttp\Exception\RequestException $e) { 88 | $this->phpariObject->lasterror = $e->getMessage(); 89 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 90 | return (int)$e->getCode(); 91 | } catch (\GuzzleHttp\Exception\ClientException $e) { 92 | $this->phpariObject->lasterror = $e->getMessage(); 93 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 94 | return (int)$e->getCode(); 95 | } catch (\GuzzleHttp\Exception\ServerException $e) { 96 | $this->phpariObject->lasterror = $e->getMessage(); 97 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 98 | return (int)$e->getCode(); 99 | } catch (Exception $e) { 100 | $this->phpariObject->lasterror = $e->getMessage(); 101 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 102 | 103 | return FALSE; 104 | } 105 | 106 | } 107 | 108 | /** 109 | * @param null $variable 110 | * 111 | * @return bool 112 | */ 113 | public function getGlobalVariable($variable = NULL) 114 | { 115 | try { 116 | 117 | $result = FALSE; 118 | 119 | if (is_null($variable)) 120 | throw new Exception("Global variable name not provided or is null", 503); 121 | 122 | $uri = "/asterisk/variable?variable=" . $variable; 123 | 124 | $jsonResult = $this->pestObject->get($uri); 125 | 126 | $result = json_decode($this->ariEndpointClient->get($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 127 | 128 | return $result; 129 | 130 | } catch (\GuzzleHttp\Exception\RequestException $e) { 131 | $this->phpariObject->lasterror = $e->getMessage(); 132 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 133 | return (int)$e->getCode(); 134 | } catch (\GuzzleHttp\Exception\ClientException $e) { 135 | $this->phpariObject->lasterror = $e->getMessage(); 136 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 137 | return (int)$e->getCode(); 138 | } catch (\GuzzleHttp\Exception\ServerException $e) { 139 | $this->phpariObject->lasterror = $e->getMessage(); 140 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 141 | return (int)$e->getCode(); 142 | } catch (Exception $e) { 143 | $this->phpariObject->lasterror = $e->getMessage(); 144 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 145 | 146 | return FALSE; 147 | } 148 | } 149 | 150 | /* 151 | * This is an alias to setGlobalVariable 152 | */ 153 | public function get_global_variable($variable = NULL) 154 | { 155 | $this->setGlobalVariable($variable); 156 | } 157 | 158 | /** 159 | * @param null $variable 160 | * @param null $value 161 | * 162 | * @return mixed 163 | */ 164 | public function setGlobalVariable($variable = NULL, $value = NULL) 165 | { 166 | try { 167 | 168 | $result = FALSE; 169 | 170 | if (is_null($variable)) 171 | throw new Exception("Global variable name not provided or is null", 503); 172 | 173 | if (is_null($value)) 174 | throw new Exception("Global variable value not provided or is null", 503); 175 | 176 | $uri = "/asterisk/variable"; 177 | $postData = array("variable" => $variable, "value" => $value); 178 | 179 | $this->ariEndpointOptions['json'] = $postData; 180 | $result = json_decode($this->ariEndpointClient->post($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 181 | 182 | return $result; 183 | 184 | } catch (\GuzzleHttp\Exception\RequestException $e) { 185 | $this->phpariObject->lasterror = $e->getMessage(); 186 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 187 | return (int)$e->getCode(); 188 | } catch (\GuzzleHttp\Exception\ClientException $e) { 189 | $this->phpariObject->lasterror = $e->getMessage(); 190 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 191 | return (int)$e->getCode(); 192 | } catch (\GuzzleHttp\Exception\ServerException $e) { 193 | $this->phpariObject->lasterror = $e->getMessage(); 194 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 195 | return (int)$e->getCode(); 196 | } catch (Exception $e) { 197 | $this->phpariObject->lasterror = $e->getMessage(); 198 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 199 | 200 | return FALSE; 201 | } 202 | } 203 | 204 | /* 205 | * This is an alias to setGlobalVariable 206 | */ 207 | public function set_global_variable($variable = NULL, $value = NULL) 208 | { 209 | $this->setGlobalVariable($variable, $value); 210 | } 211 | 212 | /** 213 | * @param null $configClass 214 | * @param null $objectType 215 | * @param null $id 216 | * @return bool 217 | */ 218 | public function getDynamicConfigurationObject($configClass = NULL, $objectType = NULL, $id = NULL) 219 | { 220 | try { 221 | 222 | $result = FALSE; 223 | 224 | if (is_null($configClass)) 225 | throw new Exception("configClass variable name not provided or is null", 503); 226 | 227 | if (is_null($objectType)) 228 | throw new Exception("objectType variable value not provided or is null", 503); 229 | 230 | if (is_null($id)) 231 | throw new Exception("id variable value not provided or is null", 503); 232 | 233 | $uri = "/asterisk/config/dynamic/" . $configClass . "/" . $objectType . "/" . $id; 234 | $result = json_decode($this->ariEndpointClient->get($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 235 | 236 | return $result; 237 | 238 | } catch (\GuzzleHttp\Exception\RequestException $e) { 239 | $this->phpariObject->lasterror = $e->getMessage(); 240 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 241 | return (int)$e->getCode(); 242 | } catch (\GuzzleHttp\Exception\ClientException $e) { 243 | $this->phpariObject->lasterror = $e->getMessage(); 244 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 245 | return (int)$e->getCode(); 246 | } catch (\GuzzleHttp\Exception\ServerException $e) { 247 | $this->phpariObject->lasterror = $e->getMessage(); 248 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 249 | return (int)$e->getCode(); 250 | } catch (Exception $e) { 251 | $this->phpariObject->lasterror = $e->getMessage(); 252 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 253 | 254 | return FALSE; 255 | } 256 | } 257 | 258 | /** 259 | * @param null $configClass 260 | * @param null $objectType 261 | * @param null $id 262 | * @return bool 263 | */ 264 | public function get_dynamic_configuration_object($configClass = NULL, $objectType = NULL, $id = NULL) 265 | { 266 | return $this->getDynamicConfigurationObject($configClass, $objectType, $id); 267 | } 268 | 269 | /** 270 | * @param null $configClass 271 | * @param null $objectType 272 | * @param null $id 273 | * @param null $fields 274 | * @return bool 275 | */ 276 | public function putDynamicConfigurationObject($configClass = NULL, $objectType = NULL, $id = NULL, $fields = NULL) 277 | { 278 | try { 279 | 280 | $result = FALSE; 281 | 282 | if (is_null($configClass)) 283 | throw new Exception("configClass variable name not provided or is null", 503); 284 | 285 | if (is_null($objectType)) 286 | throw new Exception("objectType variable value not provided or is null", 503); 287 | 288 | if (is_null($id)) 289 | throw new Exception("id variable value not provided or is null", 503); 290 | 291 | if (is_null($fields)) 292 | throw new Exception("id variable value not provided or is null", 503); 293 | 294 | $uri = "/asterisk/config/dynamic/" . $configClass . "/" . $objectType . "/" . $id; 295 | 296 | $this->ariEndpointOptions['json'] = $fields; 297 | $result = json_decode($this->ariEndpointClient->put($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 298 | 299 | return $result; 300 | 301 | } catch (\GuzzleHttp\Exception\RequestException $e) { 302 | $this->phpariObject->lasterror = $e->getMessage(); 303 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 304 | return (int)$e->getCode(); 305 | } catch (\GuzzleHttp\Exception\ClientException $e) { 306 | $this->phpariObject->lasterror = $e->getMessage(); 307 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 308 | return (int)$e->getCode(); 309 | } catch (\GuzzleHttp\Exception\ServerException $e) { 310 | $this->phpariObject->lasterror = $e->getMessage(); 311 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 312 | return (int)$e->getCode(); 313 | } catch (Exception $e) { 314 | $this->phpariObject->lasterror = $e->getMessage(); 315 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 316 | 317 | return FALSE; 318 | } 319 | } 320 | 321 | /** 322 | * @param null $configClass 323 | * @param null $objectType 324 | * @param null $id 325 | * @param null $fields 326 | * @return bool 327 | */ 328 | public function put_dynamic_configuration_object($configClass = NULL, $objectType = NULL, $id = NULL, $fields = NULL) 329 | { 330 | return $this->putDynamicConfigurationObject($configClass, $objectType, $id); 331 | } 332 | 333 | /** 334 | * @param null $configClass 335 | * @param null $objectType 336 | * @param null $id 337 | * @return bool 338 | */ 339 | public function deleteDynamicConfigurationObject($configClass = NULL, $objectType = NULL, $id = NULL) 340 | { 341 | try { 342 | 343 | $result = FALSE; 344 | 345 | if (is_null($configClass)) 346 | throw new Exception("configClass variable name not provided or is null", 503); 347 | 348 | if (is_null($objectType)) 349 | throw new Exception("objectType variable value not provided or is null", 503); 350 | 351 | if (is_null($id)) 352 | throw new Exception("id variable value not provided or is null", 503); 353 | 354 | 355 | $uri = "/asterisk/config/dynamic/" . $configClass . "/" . $objectType . "/" . $id; 356 | 357 | $result = json_decode($this->ariEndpointClient->delete($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 358 | 359 | return $result; 360 | 361 | } catch (\GuzzleHttp\Exception\RequestException $e) { 362 | $this->phpariObject->lasterror = $e->getMessage(); 363 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 364 | return (int)$e->getCode(); 365 | } catch (\GuzzleHttp\Exception\ClientException $e) { 366 | $this->phpariObject->lasterror = $e->getMessage(); 367 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 368 | return (int)$e->getCode(); 369 | } catch (\GuzzleHttp\Exception\ServerException $e) { 370 | $this->phpariObject->lasterror = $e->getMessage(); 371 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 372 | return (int)$e->getCode(); 373 | } catch (Exception $e) { 374 | $this->phpariObject->lasterror = $e->getMessage(); 375 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 376 | 377 | return FALSE; 378 | } 379 | } 380 | 381 | /** 382 | * @param null $configClass 383 | * @param null $objectType 384 | * @param null $id 385 | * @return bool 386 | */ 387 | public function delete_dynamic_configuration_object($configClass = NULL, $objectType = NULL, $id = NULL) 388 | { 389 | return $this->deleteDynamicConfigurationObject($configClass, $objectType, $id); 390 | } 391 | 392 | /** 393 | * @param string $action 394 | * @param null $module_name 395 | * @return bool 396 | */ 397 | private function ari_module_handler($action = "get", $module_name = NULL) 398 | { 399 | try { 400 | 401 | $result = FALSE; 402 | 403 | $uri = "/asterisk/modules" . $module_name; 404 | 405 | switch ($action) { 406 | case "get": 407 | $result = json_decode($this->ariEndpointClient->get($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 408 | break; 409 | case "load": 410 | 411 | if (is_null($module_name)) 412 | throw new Exception("module_name variable name not provided or is null", 503); 413 | 414 | $result = json_decode($this->ariEndpointClient->post($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 415 | break; 416 | case "unload": 417 | 418 | if (is_null($module_name)) 419 | throw new Exception("module_name variable name not provided or is null", 503); 420 | 421 | $result = json_decode($this->ariEndpointClient->delete($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 422 | break; 423 | case "reload": 424 | 425 | if (is_null($module_name)) 426 | throw new Exception("module_name variable name not provided or is null", 503); 427 | 428 | $result = json_decode($this->ariEndpointClient->put($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 429 | break; 430 | } 431 | 432 | return $result; 433 | 434 | } catch (\GuzzleHttp\Exception\RequestException $e) { 435 | $this->phpariObject->lasterror = $e->getMessage(); 436 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 437 | return (int)$e->getCode(); 438 | } catch (\GuzzleHttp\Exception\ClientException $e) { 439 | $this->phpariObject->lasterror = $e->getMessage(); 440 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 441 | return (int)$e->getCode(); 442 | } catch (\GuzzleHttp\Exception\ServerException $e) { 443 | $this->phpariObject->lasterror = $e->getMessage(); 444 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 445 | return (int)$e->getCode(); 446 | } catch (Exception $e) { 447 | $this->phpariObject->lasterror = $e->getMessage(); 448 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 449 | 450 | return FALSE; 451 | } 452 | } 453 | 454 | /** 455 | * @param null $module_name 456 | * @return bool 457 | */ 458 | public function getModule($module_name = NULL) 459 | { 460 | return $this->ari_module_handler("get", $module_name); 461 | } 462 | 463 | /** 464 | * @param null $module_name 465 | * @return bool 466 | */ 467 | public function get_module($module_name = NULL) 468 | { 469 | return $this->getModule($module_name); 470 | } 471 | 472 | /** 473 | * @param null $module_name 474 | * @return bool 475 | */ 476 | public function loadModule($module_name = NULL) 477 | { 478 | return $this->ari_module_handler("load", $module_name); 479 | } 480 | 481 | /** 482 | * @param null $module_name 483 | * @return bool 484 | */ 485 | public function load_module($module_name = NULL) 486 | { 487 | return $this->loadModule($module_name); 488 | } 489 | 490 | /** 491 | * @param null $module_name 492 | * @return bool 493 | */ 494 | public function unloadModule($module_name = NULL) 495 | { 496 | return $this->ari_module_handler("unload", $module_name); 497 | } 498 | 499 | /** 500 | * @param null $module_name 501 | * @return bool 502 | */ 503 | public function unload_module($module_name = NULL) 504 | { 505 | return $this->unloadModule($module_name); 506 | } 507 | 508 | /** 509 | * @param null $module_name 510 | * @return bool 511 | */ 512 | public function reloadModule($module_name = NULL) 513 | { 514 | return $this->ari_module_handler("reload", $module_name); 515 | } 516 | 517 | /** 518 | * @param null $module_name 519 | * @return bool 520 | */ 521 | public function reload_module($module_name = NULL) 522 | { 523 | return $this->reloadModule($module_name); 524 | } 525 | 526 | public function getLogChannels() 527 | { 528 | try { 529 | 530 | $result = FALSE; 531 | 532 | $uri = "/asterisk/logging"; 533 | 534 | $result = json_decode($this->ariEndpointClient->get($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 535 | 536 | return $result; 537 | 538 | } catch (\GuzzleHttp\Exception\RequestException $e) { 539 | $this->phpariObject->lasterror = $e->getMessage(); 540 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 541 | return (int)$e->getCode(); 542 | } catch (\GuzzleHttp\Exception\ClientException $e) { 543 | $this->phpariObject->lasterror = $e->getMessage(); 544 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 545 | return (int)$e->getCode(); 546 | } catch (\GuzzleHttp\Exception\ServerException $e) { 547 | $this->phpariObject->lasterror = $e->getMessage(); 548 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 549 | return (int)$e->getCode(); 550 | } catch (Exception $e) { 551 | $this->phpariObject->lasterror = $e->getMessage(); 552 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 553 | 554 | return FALSE; 555 | } 556 | } 557 | 558 | public function get_log_channels() 559 | { 560 | return $this->getLogChannels(); 561 | } 562 | 563 | 564 | public function addLogChannel($log_channel_name = NULL, $configuration = NULL) 565 | { 566 | try { 567 | 568 | $result = FALSE; 569 | 570 | if (is_null($log_channel_name)) 571 | throw new Exception("log_channel_name variable name not provided or is null", 503); 572 | 573 | if (is_null($configuration)) 574 | throw new Exception("configuration variable name not provided or is null", 503); 575 | 576 | $uri = "/asterisk/logging/" . $log_channel_name; 577 | 578 | $this->ariEndpointOptions['json'] = $configuration; 579 | $result = json_decode($this->ariEndpointClient->post($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 580 | 581 | return $result; 582 | 583 | } catch (\GuzzleHttp\Exception\RequestException $e) { 584 | $this->phpariObject->lasterror = $e->getMessage(); 585 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 586 | return (int)$e->getCode(); 587 | } catch (\GuzzleHttp\Exception\ClientException $e) { 588 | $this->phpariObject->lasterror = $e->getMessage(); 589 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 590 | return (int)$e->getCode(); 591 | } catch (\GuzzleHttp\Exception\ServerException $e) { 592 | $this->phpariObject->lasterror = $e->getMessage(); 593 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 594 | return (int)$e->getCode(); 595 | } catch (Exception $e) { 596 | $this->phpariObject->lasterror = $e->getMessage(); 597 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 598 | 599 | return FALSE; 600 | } 601 | } 602 | 603 | public function add_log_channel($log_channel_name = NULL, $configuration = NULL) 604 | { 605 | return $this->addLogChannel($log_channel_name, $configuration); 606 | } 607 | 608 | public function rotateLogChannel($log_channel_name = NULL) 609 | { 610 | try { 611 | 612 | $result = FALSE; 613 | 614 | if (is_null($log_channel_name)) 615 | throw new Exception("log_channel_name variable name not provided or is null", 503); 616 | 617 | 618 | $uri = "/asterisk/logging/" . $log_channel_name . "/rotate"; 619 | 620 | $result = json_decode($this->ariEndpointClient->put($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 621 | 622 | return $result; 623 | 624 | } catch (\GuzzleHttp\Exception\RequestException $e) { 625 | $this->phpariObject->lasterror = $e->getMessage(); 626 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 627 | return (int)$e->getCode(); 628 | } catch (\GuzzleHttp\Exception\ClientException $e) { 629 | $this->phpariObject->lasterror = $e->getMessage(); 630 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 631 | return (int)$e->getCode(); 632 | } catch (\GuzzleHttp\Exception\ServerException $e) { 633 | $this->phpariObject->lasterror = $e->getMessage(); 634 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 635 | return (int)$e->getCode(); 636 | } catch (Exception $e) { 637 | $this->phpariObject->lasterror = $e->getMessage(); 638 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 639 | 640 | return FALSE; 641 | } 642 | } 643 | 644 | public function rotate_log_channel($log_channel_name = NULL) 645 | { 646 | return $this->rotateLogChannel($log_channel_name); 647 | 648 | } 649 | 650 | public function deleteLogChannel($log_channel_name = NULL) 651 | { 652 | try { 653 | 654 | $result = FALSE; 655 | 656 | if (is_null($log_channel_name)) 657 | throw new Exception("log_channel_name variable name not provided or is null", 503); 658 | 659 | $uri = "/asterisk/logging/" . $log_channel_name; 660 | 661 | $result = json_decode($this->ariEndpointClient->delete($this->ariEndpointURL . $uri, $this->ariEndpointOptions)->getBody()->getContents()); 662 | 663 | return $result; 664 | 665 | } catch (\GuzzleHttp\Exception\RequestException $e) { 666 | $this->phpariObject->lasterror = $e->getMessage(); 667 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 668 | return (int)$e->getCode(); 669 | } catch (\GuzzleHttp\Exception\ClientException $e) { 670 | $this->phpariObject->lasterror = $e->getMessage(); 671 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 672 | return (int)$e->getCode(); 673 | } catch (\GuzzleHttp\Exception\ServerException $e) { 674 | $this->phpariObject->lasterror = $e->getMessage(); 675 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 676 | return (int)$e->getCode(); 677 | } catch (Exception $e) { 678 | $this->phpariObject->lasterror = $e->getMessage(); 679 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 680 | 681 | return FALSE; 682 | } 683 | } 684 | 685 | public function delete_log_channel($log_channel_name = NULL) 686 | { 687 | return $this->deleteLogChannel($log_channel_name); 688 | } 689 | 690 | } -------------------------------------------------------------------------------- /src/interfaces/bridges.php: -------------------------------------------------------------------------------- 1 | ariEndpoint)) 38 | throw new Exception("Missing PestObject or empty string", 503); 39 | 40 | $this->phpariObject = $connObject; 41 | $this->pestObject = $connObject->ariEndpoint; 42 | 43 | } catch (Exception $e) { 44 | die("Exception raised: " . $e->getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 45 | } 46 | } 47 | 48 | /** 49 | * GET /bridges 50 | * List all active bridges in Asterisk. 51 | * 52 | * @return bool 53 | */ 54 | public function show() 55 | { 56 | try { 57 | 58 | if (is_null($this->pestObject)) 59 | throw new Exception("PEST Object not provided or is null", 503); 60 | 61 | $uri = "/bridges"; 62 | $result = $this->pestObject->get($uri); 63 | 64 | return $result; 65 | 66 | 67 | } catch (Exception $e) { 68 | $this->phpariObject->lasterror = $e->getMessage(); 69 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 70 | 71 | return FALSE; 72 | } 73 | } 74 | 75 | /** 76 | * This function is an alias to 'show' - will be deprecated in phpari 2.0 77 | * 78 | * @return mixed 79 | */ 80 | public function bridges_list() 81 | { 82 | return $this->show(); 83 | } 84 | 85 | /** 86 | * POST /bridges 87 | * Create or Update a new or existing ARI bridge. 88 | * This bridge persists until it has been shut down, or Asterisk has been shut down. 89 | * 90 | * Please note, ARI bridges have nothing to do with ConfBridge or native Asterisk bridging 91 | * 92 | * @param null $type - Comma separated list of bridge type attributes (mixing, holding, dtmf_events, proxy_media). 93 | * @param null $bridgeId - Unique ID to give to the bridge being created. 94 | * @param null $name - Name to give to the bridge being created. 95 | * 96 | * @return bool 97 | */ 98 | public function create($type = NULL, $bridgeId = NULL, $name = NULL) 99 | { 100 | try { 101 | 102 | $postOBJ = array(); 103 | 104 | if (!is_null($type)) 105 | $postOBJ['type'] = $type; 106 | 107 | if (!is_null($name)) 108 | $postOBJ['name'] = $name; 109 | 110 | $uri = (is_null($bridgeId)) ? "/bridges" : "/bridges/" . $bridgeId; 111 | 112 | $result = $this->pestObject->post($uri, $postOBJ); 113 | 114 | return $result; 115 | 116 | } catch (Exception $e) { 117 | $this->phpariObject->lasterror = $e->getMessage(); 118 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 119 | 120 | return FALSE; 121 | } 122 | } 123 | 124 | /** 125 | * This function is an alias to 'create' - will be deprecated in phpari 2.0 126 | * 127 | * @return mixed 128 | */ 129 | public function bridge_create($type = NULL, $bridgeId = NULL, $name = NULL) 130 | { 131 | return $this->create($type, $bridgeId, $name); 132 | } 133 | 134 | 135 | /** 136 | * This function is an alias to 'create' - will be deprecated in phpari 2.0 137 | * 138 | * @return mixed 139 | */ 140 | public function bridge_create_update($type = NULL, $bridgeId = NULL, $name = NULL) 141 | { 142 | return $this->create($type, $bridgeId, $name); 143 | } 144 | 145 | /** 146 | * GET /bridges/{bridgeId} 147 | * Get bridge details. 148 | * 149 | * @param null $bridgeId 150 | * 151 | * @return bool 152 | */ 153 | public function details($bridgeId = NULL) 154 | { 155 | 156 | try { 157 | 158 | if (is_null($bridgeId)) 159 | throw new Exception("BridgeID not provided or is null", 503); 160 | 161 | $uri = "/bridges/" . $bridgeId; 162 | $result = $this->pestObject->get($uri); 163 | 164 | return $result; 165 | 166 | } catch (Exception $e) { 167 | return FALSE; 168 | } 169 | 170 | } 171 | 172 | /** 173 | * This function is an alias to 'details' - will be deprecated in phpari 2.0 174 | * 175 | * @return mixed 176 | */ 177 | public function bridge_details($bridgeId = NULL) 178 | { 179 | $this->bridge_details($bridgeId); 180 | } 181 | 182 | /** 183 | * DELETE /bridges/{bridgeId} 184 | * Shut down a bridge. 185 | * If any channels are in this bridge, 186 | * they will be removed and resume whatever they were doing beforehand. 187 | * 188 | * @param null $bridgeId 189 | * 190 | * @return bool 191 | */ 192 | public function terminate($bridgeId = NULL) 193 | { 194 | try { 195 | 196 | if (is_null($bridgeId)) 197 | throw new Exception("BridgeID not provided or is null", 503); 198 | 199 | $uri = "/bridges/" . $bridgeId; 200 | $result = $this->pestObject->delete($uri); 201 | 202 | return $result; 203 | 204 | } catch (Exception $e) { 205 | $this->phpariObject->lasterror = $e->getMessage(); 206 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 207 | 208 | return FALSE; 209 | } 210 | } 211 | 212 | /** 213 | * This function is an alias to 'terminate' - will be deprecated in phpari 2.0 214 | * 215 | * @return mixed 216 | */ 217 | public function bridge_delete($bridgeId = NULL) 218 | { 219 | return $this->terminate($bridgeId); 220 | } 221 | 222 | /** 223 | * 224 | * POST /bridges/{bridgeId}/addChannel 225 | * Add a channel to a bridge. 226 | * 227 | * @param null $bridgeId - Bridge's id 228 | * @param null $channel - (required) Ids of channels to add to bridge 229 | * @param null $role - Channel's role in the bridge 230 | * 231 | * @return bool 232 | * 233 | * NOTE: Change in API occured here, old addchannel function is now deprecated 234 | */ 235 | public function addChannel($bridgeId = NULL, $channel = NULL, $role = NULL) 236 | { 237 | try { 238 | 239 | if (is_null($bridgeId)) 240 | throw new Exception("BridgeID is not provided or is null", 503); 241 | 242 | if (is_null($channel)) 243 | throw new Exception("Channel is not provided or is null", 503); 244 | 245 | $postObj = array(); 246 | $postObj['channel'] = $channel; 247 | 248 | if (!is_null($role)) 249 | $postObj['role'] = $role; 250 | 251 | $uri = "/bridges/" . $bridgeId . "/addChannel"; 252 | $result = $this->pestObject->post($uri, $postObj); 253 | 254 | return $result; 255 | 256 | } catch (Exception $e) { 257 | $this->phpariObject->lasterror = $e->getMessage(); 258 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 259 | 260 | return FALSE; 261 | } 262 | } 263 | 264 | /** 265 | * This function is an alias to 'addChannel' - will be deprecated in phpari 2.0 266 | * 267 | * @return mixed 268 | */ 269 | public function bridge_addchannel($bridgeId = NULL, $channel = NULL, $role = NULL) 270 | { 271 | return $this->addChannel($bridgeId, $channel, $role); 272 | } 273 | 274 | /** 275 | * 276 | * POST /bridges/{bridgeId}/removeChannel 277 | * Remove a channel to a bridge. 278 | * 279 | * @param null $bridgeId - Bridge's id 280 | * @param null $channel - (required) Ids of channels to add to bridge 281 | * 282 | * @return bool 283 | */ 284 | public function removeChannel($bridgeId = NULL, $channel = NULL) 285 | { 286 | try { 287 | 288 | if (is_null($bridgeId)) 289 | throw new Exception("BridgeID is not provided or is null", 503); 290 | 291 | if (is_null($channel)) 292 | throw new Exception("Channel is not provided or is null", 503); 293 | 294 | $delObj = array( 295 | 'channel' => $channel, 296 | ); 297 | 298 | $uri = "/bridges/" . $bridgeId . "/removeChannel"; 299 | $result = $this->pestObject->post($uri, $delObj); 300 | 301 | return $result; 302 | 303 | } catch (Exception $e) { 304 | $this->phpariObject->lasterror = $e->getMessage(); 305 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 306 | 307 | return FALSE; 308 | } 309 | } 310 | 311 | /** 312 | * This function is an alias to 'removechannel' - will be deprecated in phpari 2.0 313 | * 314 | * @return mixed 315 | */ 316 | public function bridge_remove_channel($bridgeId = NULL, $channel = NULL) 317 | { 318 | return $this->removeChannel($bridgeId, $channel); 319 | } 320 | 321 | /** 322 | * This function is an alias to 'removeChannel' - it's here for backward compatibility only 323 | * 324 | * @return mixed 325 | */ 326 | public function delchannel($bridgeId = NULL, $channel = NULL) 327 | { 328 | return $this->removeChannel($bridgeId, $channel); 329 | } 330 | 331 | /** 332 | * 333 | * POST /bridges/{bridgeId}/moh 334 | * Play music on hold to a bridge or change the MOH class that is playing. 335 | * 336 | * @param null $bridgeId 337 | * @param null $mohClass 338 | * 339 | * @return bool 340 | */ 341 | public function mohStart($bridgeId = NULL, $mohClass = NULL) 342 | { 343 | try { 344 | 345 | if (is_null($bridgeId)) 346 | throw new Exception("BridgeID is not provided or is null", 503); 347 | 348 | $postObj = array(); 349 | if (!is_null($mohClass)) 350 | $postObj['mohClass'] = $mohClass; 351 | 352 | $uri = '/bridges/' . $bridgeId . '/moh'; 353 | $result = $this->pestObject->post($uri, $postObj); 354 | 355 | return $result; 356 | 357 | } catch (Exception $e) { 358 | $this->phpariObject->lasterror = $e->getMessage(); 359 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 360 | 361 | return FALSE; 362 | } 363 | } 364 | 365 | /** 366 | * This function is an alias to 'moh_start' - will be deprecated in phpari 2.0 367 | * 368 | * @return mixed 369 | */ 370 | public function bridge_play_moh($bridgeId = NULL, $mohClass = NULL) 371 | { 372 | return $this->moh_start($bridgeId, $mohClass); 373 | } 374 | 375 | /** 376 | * 377 | * DELETE /bridges/{bridgeId}/moh 378 | * Stop playing music on hold to a bridge. 379 | * This will only stop music on hold being played via POST bridges/{bridgeId}/moh. 380 | * 381 | * @param null $bridgeId - Bridge's id 382 | * 383 | * @return bool 384 | */ 385 | public function mohStop($bridgeId = NULL) 386 | { 387 | try { 388 | 389 | if (is_null($bridgeId)) 390 | throw new Exception("BridgeID is not provided or is null", 503); 391 | 392 | $uri = '/bridges/' . $bridgeId . '/moh'; 393 | $result = $this->pestObject->delete($uri); 394 | 395 | return $result; 396 | 397 | } catch (Exception $e) { 398 | $this->phpariObject->lasterror = $e->getMessage(); 399 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 400 | 401 | return FALSE; 402 | } 403 | } 404 | 405 | /** 406 | * This function is an alias to 'moh_stop' - will be deprecated in phpari 2.0 407 | * 408 | * @return mixed 409 | */ 410 | public function bridge_stop_moh($bridgeId = NULL) 411 | { 412 | return $this->moh_stop($bridgeId); 413 | } 414 | 415 | /** 416 | * POST /bridges/{bridgeId}/play 417 | * Start playback of media on a bridge. 418 | * The media URI may be any of a number of URI's. Currently sound:, 419 | * recording:, number:, digits:, characters:, and tone: URI's are supported. 420 | * This operation creates a playback resource that can be used to control the playback of media (pause, rewind, fast forward, etc.) 421 | * 422 | * @param null $bridgeId - Bridge's id 423 | * @param string $media - (required) Media's URI to play. 424 | * @param string $lang - For sounds, selects language for sound. 425 | * @param int $offsetms - Number of media to skip before playing. 426 | * @param int $skipms - Number of milliseconds to skip for forward/reverse operations. 427 | * @param null $playbackId - Playback Id. 428 | * 429 | * @return bool 430 | */ 431 | public function playbackStart($bridgeId = NULL, $media = NULL, $lang = NULL, $offsetms = NULL, $skipms = NULL, $playbackId = NULL) 432 | { 433 | try { 434 | 435 | if (is_null($bridgeId)) 436 | throw new Exception("BridgeID is not provided or is null", 503); 437 | if (is_null($media)) 438 | throw new Exception("Media representation is not provided or is null", 503); 439 | 440 | $postObj = array(); 441 | $postObj['media'] = $media; 442 | 443 | if (!is_null($lang)) 444 | $postObj['lang'] = $lang; 445 | 446 | if (!is_null($offsetms)) 447 | $postObj['offsetms'] = $offsetms; 448 | 449 | if (!is_null($skipms)) 450 | $postObj['skipms'] = $skipms; 451 | 452 | if (!is_null($playbackId)) 453 | $postObj['playbkackId'] = $playbackId; 454 | 455 | $uri = (is_null($playbackId)) ? '/bridges/' . $bridgeId . '/play' : '/bridges/' . $bridgeId . '/play/' . $playbackId; 456 | $result = $this->pestObject->post($uri, $postObj); 457 | 458 | return $result; 459 | 460 | } catch (Exception $e) { 461 | $this->phpariObject->lasterror = $e->getMessage(); 462 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 463 | 464 | return FALSE; 465 | } 466 | } 467 | 468 | /** 469 | * This function is an alias to 'playback_start' - will be deprecated in phpari 2.0 470 | * 471 | * @return mixed 472 | */ 473 | public function bridge_start_playback($bridgeId = NULL, $media = NULL, $lang = NULL, $offsetms = NULL, $skipms = NULL, $playbackId = NULL) 474 | { 475 | return $this->playback_start($bridgeId, $media, $lang, $offsetms, $skipms, $playbackId); 476 | } 477 | 478 | 479 | /** 480 | * This function is an alias to 'playback_start' - will be deprecated in phpari 2.0 481 | * 482 | * @return mixed 483 | */ 484 | public function bridge_start_playback_id($bridgeId = NULL, $media = NULL, $lang = NULL, $offsetms = NULL, $skipms = NULL, $playbackId = NULL) 485 | { 486 | return $this->playback_start($bridgeId, $media, $lang, $offsetms, $skipms, $playbackId); 487 | } 488 | 489 | 490 | /** 491 | * POST /bridges/{bridgeId}/record 492 | * Start a recording. 493 | * This records the mixed audio from all 494 | * channels participating in this bridge. 495 | * 496 | * @param null $bridgeId 497 | * @param string $name - (required) Recording's filename 498 | * @param string $format - (required) Format to encode audio in 499 | * @param int $maxDurationSeconds - Maximum duration of the recording, in seconds. 0 for no limit. 500 | * @param int $maxSilenceSeconds - Maximum duration of silence, in seconds. 0 for no limit. 501 | * @param string $ifExists - Action to take if a recording with the same name already exists. 502 | * @param bool $beep - Play beep when recording begins 503 | * @param string $terminateOn - DTMF input to terminate recording. 504 | * 505 | * @return bool 506 | */ 507 | public function record( 508 | $bridgeId = NULL, 509 | $name = NULL, 510 | $format = NULL, 511 | $maxDurationSeconds = 0, 512 | $maxSilenceSeconds = 0, 513 | $ifExists = "fail", 514 | $beep = FALSE, 515 | $terminateOn = "none") 516 | { 517 | try { 518 | 519 | if (is_null($bridgeId)) 520 | throw new Exception("BridgeID is not provided or is null", 503); 521 | if (is_null($name)) 522 | throw new Exception("Recording filename is not provided or is null", 503); 523 | if (is_null($format)) 524 | throw new Exception("Format to encode audio in is not provided or is null", 503); 525 | 526 | 527 | $postObj = array( 528 | 'name' => $name, 529 | 'format' => $format, 530 | 'maxDurationSeconds' => $maxDurationSeconds, 531 | 'maxSilenceSeconds' => $maxSilenceSeconds, 532 | 'ifExists' => $ifExists, 533 | 'beep' => $beep, 534 | 'terminateOn' => $terminateOn, 535 | ); 536 | 537 | $uri = '/bridges/' . $bridgeId . '/record'; 538 | $result = $this->pestObject->post($uri, $postObj); 539 | 540 | return $result; 541 | 542 | } catch (Exception $e) { 543 | $this->phpariObject->lasterror = $e->getMessage(); 544 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 545 | 546 | return FALSE; 547 | } 548 | } 549 | 550 | /** 551 | * This function is an alias to 'record' - will be deprecated in phpari 2.0 552 | * 553 | * @return mixed 554 | */ 555 | public function bridge_start_recording( 556 | $bridgeId = NULL, 557 | $name = NULL, 558 | $format = NULL, 559 | $maxDurationSeconds = 0, 560 | $maxSilenceSeconds = 0, 561 | $ifExists = "fail", 562 | $beep = FALSE, 563 | $terminateOn = "none" 564 | 565 | ) 566 | { 567 | return $this->record($bridgeId, $name, $format, $maxDurationSeconds, $maxSilenceSeconds, $ifExists, $beep, $terminateOn); 568 | } 569 | 570 | } 571 | 572 | 573 | 574 | -------------------------------------------------------------------------------- /src/interfaces/devicestates.php: -------------------------------------------------------------------------------- 1 | ariEndpoint)) 34 | throw new Exception("Missing PestObject or empty string", 503); 35 | 36 | $this->phpariObject = $connObject; 37 | $this->pestObject = $connObject->ariEndpoint; 38 | 39 | } catch (Exception $e) { 40 | die("Exception raised: " . $e->getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 41 | } 42 | } 43 | 44 | 45 | /** 46 | * GET /deviceStates 47 | * Get a list of current device states, or the device state for a specific device name 48 | * 49 | * @return bool 50 | */ 51 | public function show($deviceName = NULL) 52 | { 53 | try { 54 | 55 | if (is_null($this->pestObject)) 56 | throw new Exception("PEST Object not provided or is null", 503); 57 | 58 | $uri = (is_null($deviceName))?"/deviceStates":"/deviceStates/" . $deviceName; 59 | $result = $this->pestObject->get($uri); 60 | return $result; 61 | 62 | } catch (Exception $e) { 63 | $this->phpariObject->lasterror = $e->getMessage(); 64 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 65 | return false; 66 | } 67 | } 68 | 69 | /** 70 | * This function is an alias to 'show' - will be deprecated in phpari 2.0 71 | * 72 | * @return mixed 73 | */ 74 | public function devicestates_list() 75 | { 76 | return $this->show(); 77 | } 78 | 79 | /** 80 | * This function is an alias to 'show' - will be deprecated in phpari 2.0 81 | * 82 | * @return mixed 83 | */ 84 | public function devicestate_currentstate($deviceName = NULL) 85 | { 86 | return $this->show($deviceName); 87 | } 88 | 89 | /** 90 | * 91 | * PUT /deviceStates/{deviceName} 92 | * Change the state of a device controlled by ARI. 93 | * (Note - implicitly creates the device state). 94 | * 95 | * 96 | * @param null $deviceName 97 | * @param null $deviceState 98 | * @return bool 99 | */ 100 | public function set($deviceName = NULL, $deviceState = NULL) 101 | { 102 | try { 103 | 104 | if (is_null($deviceName)) 105 | throw new Exception("Device name is not provided or is null", 503); 106 | if (is_null($deviceState)) 107 | throw new Exception("Device state name is not provided or is null", 503); 108 | 109 | $putObj = array( 110 | 'deviceState' =>$deviceState 111 | ); 112 | 113 | $uri = "/deviceStates/".$deviceName; 114 | $result = $this->pestObject->put($uri,$putObj); 115 | 116 | return $result; 117 | 118 | } catch (Exception $e) { 119 | $this->phpariObject->lasterror = $e->getMessage(); 120 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 121 | return false; 122 | } 123 | } 124 | 125 | /** 126 | * This function is an alias to 'set' - will be deprecated in phpari 2.0 127 | * 128 | * @return mixed 129 | */ 130 | public function devicestate_changestate($deviceName = NULL, $deviceState = NULL) 131 | { 132 | return $this->set($deviceName, $deviceState); 133 | } 134 | 135 | 136 | /** 137 | * DELETE /deviceStates/{deviceName} 138 | * Destroy a device-state controlled by ARI. 139 | * 140 | * @param null $deviceName 141 | * @return bool 142 | */ 143 | public function remove($deviceName = NULL) 144 | { 145 | try { 146 | 147 | if (is_null($deviceName)) 148 | throw new Exception("Device name is not provided or is null", 503); 149 | 150 | $uri = "/deviceStates/".$deviceName; 151 | $result = $this->pestObject->delete($uri); 152 | 153 | return $result; 154 | 155 | } catch (Exception $e) { 156 | $this->phpariObject->lasterror = $e->getMessage(); 157 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 158 | return false; 159 | } 160 | } 161 | 162 | /** 163 | * This function is an alias to 'remove' - will be deprecated in phpari 2.0 164 | * 165 | * @return mixed 166 | */ 167 | public function devicestate_deletestate($deviceName = NULL) 168 | { 169 | return $this->remove($deviceName); 170 | } 171 | } 172 | 173 | 174 | -------------------------------------------------------------------------------- /src/interfaces/endpoints.php: -------------------------------------------------------------------------------- 1 | ariEndpoint)) 35 | throw new Exception("Missing PestObject or empty string", 503); 36 | 37 | $this->phpariObject = $connObject; 38 | $this->pestObject = $connObject->ariEndpoint; 39 | 40 | } catch (Exception $e) { 41 | die("Exception raised: " . $e->getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 42 | } 43 | } 44 | 45 | /** 46 | * List all endpoints. If $tech is provided, filter the list according to the technology specified 47 | * If both $tech and $resouse are provided, get the details for a specific endpoint. 48 | * 49 | * @param null $tech 50 | * @param null $resource 51 | * 52 | * @return mixed 53 | */ 54 | public function show($tech = NULL, $resource = NULL) 55 | { 56 | try { 57 | 58 | if (is_null($this->pestObject)) 59 | throw new Exception("PEST Object not provided or is null", 503); 60 | 61 | $uri = "/endpoints"; 62 | if (!is_null($tech)) { 63 | 64 | $uri .= "/" . $tech; 65 | $uri .= (!is_null($resource))?"/" . $resource:""; 66 | } 67 | 68 | $result = $this->pestObject->get($uri); 69 | 70 | return $result; 71 | 72 | 73 | } catch (Exception $e) { 74 | $this->phpariObject->lasterror = $e->getMessage(); 75 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 76 | 77 | return FALSE; 78 | } 79 | } 80 | 81 | /** 82 | * This function is an alias to 'show' - will be deprecated in phpari 2.0 83 | * 84 | * @return mixed 85 | */ 86 | public function endpoints_list() 87 | { 88 | return $this->show(); 89 | } 90 | 91 | /** 92 | * This function is an alias to 'show' - will be deprecated in phpari 2.0 93 | * 94 | * @return mixed 95 | */ 96 | public function endpoints_tech($tech = NULL) 97 | { 98 | return $this->show($tech); 99 | } 100 | 101 | /** 102 | * This function is an alias to 'show' - will be deprecated in phpari 2.0 103 | * 104 | * @return mixed 105 | */ 106 | public function endpoints_tech_details($tech = NULL, $resource = NULL) 107 | { 108 | return $this->show($tech, $resource); 109 | } 110 | 111 | /** 112 | * 113 | * Send a message to some technology URI or endpoint. 114 | * TODO somehow just can't create PUT method to the Asterisk server response : "message": "Invalid method" 115 | * 116 | * 117 | * @param null $to 118 | * @param null $from 119 | * @param null $body 120 | * @param null $variables - MUST BE ASSOCIATIVE ARRAY 121 | * 122 | * @return bool 123 | */ 124 | public function sendmessage($to = NULL, $from = NULL, $body = NULL, $variables = NULL) 125 | { 126 | try { 127 | 128 | if (is_null($to)) 129 | throw new Exception("endpoint name not provided or is null", 503); 130 | 131 | if (is_null($from)) 132 | throw new Exception("endpoint name not provided or is null", 503); 133 | 134 | $uri = "/endpoints/sendMessage"; 135 | 136 | /* Validate technologies */ 137 | list($res_to, $address_to) = explode(":", $to); 138 | switch(strtoupper($res_to)) { 139 | case "SIP": 140 | case "PJSIP": 141 | case "XMPP": 142 | break; 143 | default: 144 | throw new Exception("To resource is of invalid resource type"); 145 | break; 146 | } 147 | 148 | list($res_from, $address_from) = explode(":", $from); 149 | switch(strtoupper($res_from)) { 150 | case "SIP": 151 | case "PJSIP": 152 | case "XMPP": 153 | break; 154 | default: 155 | throw new Exception("From resource is of invalid resource type"); 156 | break; 157 | } 158 | 159 | $message = array( 160 | 'to' => $to, 161 | 'from' => $from, 162 | 'body' => $body 163 | ); 164 | 165 | $message = (isAssoc($variables))?array_merge($message, $variables):$message; 166 | 167 | $result = $this->pestObject->put($uri, $message); 168 | 169 | return $result; 170 | 171 | } catch (Exception $e) { 172 | $this->phpariObject->lasterror = $e->getMessage(); 173 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 174 | 175 | return FALSE; 176 | } 177 | } 178 | 179 | /** 180 | * This function is an alias to 'sendmessage' - will be deprecated in phpari 2.0 181 | * 182 | * @return mixed 183 | */ 184 | public function endpoint_sendmessage($to = NULL, $from = NULL, $body = NULL) 185 | { 186 | return $this->sendmessage($to, $from, $body); 187 | } 188 | 189 | /** 190 | * Send a message to some endpoint in a technology. 191 | * 192 | * PUT /endpoints/{tech}/{resource}/sendMessage 193 | * 194 | * @param string $tech - Technology of the endpoint 195 | * @param string $resource - ID of the endpoint 196 | * @param string $body - The body of the message 197 | * @param null $from - (required) 198 | * 199 | * @return bool 200 | */ 201 | public function uri_sendmessage($tech = NULL, $resource = NULL, $body = NULL, $from = NULL) 202 | { 203 | try { 204 | 205 | if (is_null($tech)) 206 | throw new Exception("Technology is not provided or is null", 503); 207 | 208 | if (is_null($resource)) 209 | throw new Exception("Technology is not provided or is null", 503); 210 | 211 | if (is_null($from)) 212 | throw new Exception("Sender tech/endpoint uri is not provided or is null", 503); 213 | 214 | /* Validate technologies */ 215 | list($res_from, $address_from) = explode(":", $from); 216 | switch(strtoupper($res_from)) { 217 | case "SIP": 218 | case "PJSIP": 219 | case "XMPP": 220 | break; 221 | default: 222 | throw new Exception("From resource is of invalid resource type"); 223 | break; 224 | } 225 | 226 | $putObj = array( 227 | 'body' => $body, 228 | 'from' => $from 229 | ); 230 | 231 | 232 | $uri = "/endpoints/" . $tech . "/" . $resource . "/sendMessage"; 233 | $result = $this->pestObject->put($uri, $putObj); 234 | 235 | return $result; 236 | 237 | } catch (Exception $e) { 238 | $this->phpariObject->lasterror = $e->getMessage(); 239 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 240 | 241 | return FALSE; 242 | } 243 | } 244 | 245 | public function endpoint_sendmessage_intech($tech = NULL, $resource = NULL, $body = NULL, $from = NULL) 246 | { 247 | return $this->uri_sendmessage($tech, $resource, $body, $from); 248 | } 249 | } 250 | 251 | 252 | 253 | 254 | 255 | 256 | -------------------------------------------------------------------------------- /src/interfaces/events.php: -------------------------------------------------------------------------------- 1 | ariEndpoint)) 35 | throw new Exception("Missing PestObject or empty string", 503); 36 | 37 | $this->phpariObject = $connObject; 38 | $this->pestObject = $connObject->ariEndpoint; 39 | 40 | } catch (Exception $e) { 41 | die("Exception raised: " . $e->getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 42 | } 43 | } 44 | 45 | /** 46 | * GET /events 47 | * WebSocket connection for events. 48 | * 49 | * @param null $app 50 | * 51 | * @return mixed 52 | */ 53 | public function events($app = NULL) 54 | { 55 | try { 56 | 57 | if (is_null($app)) 58 | throw new Exception("App name is not provided or is null", 503); 59 | 60 | $uri = "/events"; 61 | $getObj = array('app' => $app); 62 | 63 | $result = $this->pestObject->get($uri, $getObj); 64 | return $result; 65 | 66 | 67 | } catch (Exception $e) { 68 | $this->phpariObject->lasterror = $e->getMessage(); 69 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 70 | return false; 71 | } 72 | } 73 | 74 | /** 75 | * 76 | * POST /events/user/{eventName} 77 | * 78 | * Generate a user event. 79 | * 80 | * @param string $eventName - Event name 81 | * @param string $application - (required) The name of the application that will receive this event 82 | * @param string $channelID - Name of the Channel - source part 83 | * @param string $bridge - Name of the bridge - source part 84 | * @param string $endpoint - Name of the endpoints - source part 85 | * @param string $deviceName - The name of the device - source part 86 | * @param array $variables - Ex. array("key1" => "value1" , "key2" => "value2") 87 | * @return bool 88 | */ 89 | public function event_generate($eventName = NULL, 90 | $application = NULL, 91 | $channelID = NULL, 92 | $bridge = NULL, 93 | $endpoint = NULL, 94 | $deviceName = NULL, 95 | $variables = array()) 96 | { 97 | 98 | try { 99 | 100 | if (is_null($application)) 101 | throw new Exception("Application name is not provided or is null", 503); 102 | if (is_null($eventName)) 103 | throw new Exception("Event name is not provided or is null", 503); 104 | 105 | 106 | $uri = "/events/user/" . $eventName; 107 | $postObj = array( 108 | 'application' => $application, 109 | 'source' => array( 110 | 'channel' => $channelID, 111 | 'bridge' => $bridge, 112 | 'endpoint' => $endpoint, 113 | 'deviceState' => $deviceName 114 | ), 115 | 'variables' => $variables 116 | ); 117 | 118 | $result = $this->pestObject->post($uri, $postObj); 119 | return $result; 120 | 121 | } catch (Exception $e) { 122 | $this->phpariObject->lasterror = $e->getMessage(); 123 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 124 | return false; 125 | } 126 | } 127 | } -------------------------------------------------------------------------------- /src/interfaces/mailboxes.php: -------------------------------------------------------------------------------- 1 | ariEndpoint)) 35 | throw new Exception("Missing PestObject or empty string", 503); 36 | 37 | $this->phpariObject = $connObject; 38 | $this->pestObject = $connObject->ariEndpoint; 39 | 40 | } catch (Exception $e) { 41 | die("Exception raised: " . $e->getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 42 | } 43 | } 44 | 45 | /** 46 | * GET /mailboxes 47 | * List all mailboxes. 48 | * 49 | * @param null $mailbox 50 | * 51 | * @return mixed 52 | */ 53 | public function show($mailbox = NULL) 54 | { 55 | try { 56 | 57 | $uri = (is_null($mailbox)) ? "/mailboxes" : "/mailboxes/" . $mailBoxName; 58 | $result = $this->pestObject->get($uri); 59 | 60 | return $result; 61 | 62 | 63 | } catch (Exception $e) { 64 | $this->phpariObject->lasterror = $e->getMessage(); 65 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 66 | 67 | return FALSE; 68 | } 69 | } 70 | 71 | /** 72 | * This function is an alias to 'show' - will be deprecated in phpari 2.0 73 | * 74 | * @return mixed 75 | */ 76 | public function mailboxes_list() 77 | { 78 | return $this->show(); 79 | } 80 | 81 | 82 | /** 83 | * This function is an alias to 'show' - will be deprecated in phpari 2.0 84 | * 85 | * @return mixed 86 | */ 87 | public function mailbox_state($mailbox = NULL) 88 | { 89 | return $this->show($mailbox); 90 | } 91 | 92 | 93 | /** 94 | * PUT /mailboxes/{mailboxName} 95 | * Change the state of a mailbox. (Note - implicitly creates the mailbox). 96 | * 97 | * @param int - (required) Count of old messages in the mailbox 98 | * @param int - (required) Count of new messages in the mailbox 99 | * @param null $newMessages 100 | * 101 | * @return bool 102 | */ 103 | public function state($mailBoxName = NULL, $oldMessages = NULL, $newMessages = NULL) 104 | { 105 | try { 106 | 107 | if (is_null($mailBoxName)) 108 | throw new Exception("Mail box name is not provided or is null", 503); 109 | 110 | if (is_null($oldMessages)) 111 | throw new Exception("Old messages is not provided or is null", 503); 112 | 113 | if (is_null($newMessages)) 114 | throw new Exception("New messages is not provided or is null", 503); 115 | 116 | $uri = "/mailboxes/" . $mailBoxName; 117 | 118 | $putObj = array( 119 | 'oldMessages' => $oldMessages, 120 | 'newMessages' => $newMessages 121 | 122 | ); 123 | $result = $this->pestObject->put($uri, $putObj); 124 | 125 | return $result; 126 | 127 | 128 | } catch (Exception $e) { 129 | $this->phpariObject->lasterror = $e->getMessage(); 130 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 131 | 132 | return FALSE; 133 | } 134 | } 135 | 136 | /** 137 | * This function is an alias to 'state' - will be deprecated in phpari 2.0 138 | * 139 | * @return mixed 140 | */ 141 | public function mailbox_change_state($mailBoxName = NULL, $oldMessages = NULL, $newMessages = NULL) 142 | { 143 | return $this->state($mailBoxName, $oldMessages, $newMessages); 144 | } 145 | 146 | /** 147 | * DELETE /mailboxes/{mailboxName} 148 | * Destroy a mailbox. 149 | */ 150 | public function remove($mailbox = NULL) 151 | { 152 | try { 153 | 154 | if (is_null($mailbox)) 155 | throw new Exception("Mail box name is not provided or is null", 503); 156 | 157 | $uri = "/mailboxes/" . $mailbox; 158 | $result = $this->pestObject->delete($uri); 159 | 160 | return $result; 161 | 162 | } catch (Exception $e) { 163 | $this->phpariObject->lasterror = $e->getMessage(); 164 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 165 | 166 | return FALSE; 167 | } 168 | } 169 | 170 | /** 171 | * This function is an alias to 'remove' - will be deprecated in phpari 2.0 172 | * 173 | * @return mixed 174 | */ 175 | public function mailbox_destroy($mailbox = NULL) 176 | { 177 | $this->remove($mailbox); 178 | } 179 | 180 | } -------------------------------------------------------------------------------- /src/interfaces/playbacks.php: -------------------------------------------------------------------------------- 1 | ariEndpoint)) 35 | throw new Exception("Missing PestObject or empty string", 503); 36 | 37 | $this->phpariObject = $connObject; 38 | $this->pestObject = $connObject->ariEndpoint; 39 | 40 | } catch (Exception $e) { 41 | die("Exception raised: " . $e->getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 42 | } 43 | } 44 | 45 | /** 46 | * GET /playbacks/{playbackid} 47 | * 48 | * GET details for a specific playback ID 49 | * 50 | * @param null $playbackid 51 | * @return array|bool 52 | */ 53 | public function show($playbackid = NULL) 54 | { 55 | try { 56 | $result = FALSE; 57 | 58 | if (is_null($this->pestObject)) 59 | throw new Exception("PEST Object not provided or is null", 503); 60 | 61 | if (is_null($playbackid)) 62 | throw new Exception("playbackid is required for this operation", 503); 63 | 64 | $uri = "/playbacks/" . $playbackid; 65 | $result = $this->pestObject->get($uri); 66 | 67 | return $result; 68 | } catch (Exception $e) { 69 | $this->phpariObject->lasterror = $e->getMessage(); 70 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 71 | return FALSE; 72 | } 73 | } 74 | 75 | /** 76 | * This function is an alias to 'show' - will be deprecated in phpari 2.0 77 | * 78 | * @return mixed 79 | */ 80 | public function get_playback($playbackid = NULL) 81 | { 82 | return $this->show($playbackid); 83 | } 84 | 85 | /** 86 | * @param null $playbackid 87 | * @return array|bool 88 | */ 89 | public function remove($playbackid = NULL) 90 | { 91 | try { 92 | $result = FALSE; 93 | 94 | if (is_null($this->pestObject)) 95 | throw new Exception("PEST Object not provided or is null", 503); 96 | 97 | if (is_null($playbackid)) 98 | throw new Exception("playbackid is required for this operation", 503); 99 | 100 | $uri = "/playbacks/" . $playbackid; 101 | $result = $this->pestObject->delete($uri); 102 | 103 | return $result; 104 | } catch (Exception $e) { 105 | $this->phpariObject->lasterror = $e->getMessage(); 106 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 107 | return FALSE; 108 | } 109 | } 110 | 111 | /** 112 | * This function is an alias to 'remove' - will be deprecated in phpari 2.0 113 | * 114 | * @return mixed 115 | */ 116 | public function delete_playback($playbackid = NULL) 117 | { 118 | return $this->remove($playbackid); 119 | } 120 | 121 | /** 122 | * @param null $playbackid 123 | * @param null $control 124 | * @return array|bool 125 | */ 126 | public function control($playbackid = NULL, $control = NULL) 127 | { 128 | try { 129 | $result = FALSE; 130 | 131 | if (is_null($this->pestObject)) 132 | throw new Exception("PEST Object not provided or is null", 503); 133 | 134 | if (is_null($playbackid)) 135 | throw new Exception("playbackid is required for this operation", 503); 136 | 137 | if (is_null($control)) 138 | throw new Exception("control is required for this operation", 503); 139 | 140 | switch (strtolower($control)) { 141 | case "restart": 142 | case "pause": 143 | case "unpause": 144 | case "reverse": 145 | case "forward": 146 | break; 147 | default: 148 | throw new Exception("control property is unknown", 503); 149 | break; 150 | } 151 | 152 | $uri = "/playbacks/" . $playbackid . "/control"; 153 | $result = $this->pestObject->post($uri, array('operation' => $control)); 154 | 155 | return $result; 156 | } catch (Exception $e) { 157 | $this->phpariObject->lasterror = $e->getMessage(); 158 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 159 | return FALSE; 160 | } 161 | } 162 | 163 | /** 164 | * This function is an alias to 'control' - will be deprecated in phpari 2.0 165 | * 166 | * @return mixed 167 | */ 168 | public function control_playback($playbackid = NULL, $control = NULL) 169 | { 170 | return $this->control($playbackid, $control); 171 | } 172 | } 173 | -------------------------------------------------------------------------------- /src/interfaces/recordings.php: -------------------------------------------------------------------------------- 1 | ariEndpoint)) 36 | throw new Exception("Missing PestObject or empty string", 503); 37 | 38 | $this->phpariObject = $connObject; 39 | $this->pestObject = $connObject->ariEndpoint; 40 | 41 | } catch (Exception $e) { 42 | die("Exception raised: " . $e->getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 43 | } 44 | } 45 | 46 | /** 47 | * Perform actions on stored recordings. List (show), Details(show), Delete(delete), Copy(copy) 48 | * 49 | * @param null $action 50 | * @param null $recordingName 51 | * @param null $destinationRecording 52 | * 53 | * @return mixed 54 | */ 55 | public function stored($action = NULL, $recordingName = NULL, $destinationRecording = NULL) 56 | { 57 | try { 58 | 59 | $uri = "/recordings/stored"; 60 | 61 | if (is_null($action)) 62 | throw new Exception("action not specified or is null", 503); 63 | 64 | switch ($action) { 65 | case "show": 66 | case "list": 67 | $uri .= (!is_null($recordingName)) ? "/" . $recordingName : ""; 68 | $result = $this->pestObject->get($uri); 69 | break; 70 | default: 71 | if (is_null($recordingName)) 72 | throw new Exception("recording name not specified or is null", 503); 73 | 74 | $uri .= "/" . $recordingName; 75 | 76 | switch ($action) { 77 | case "delete": 78 | $result = $this->pestObject->delete($uri); 79 | break; 80 | case "copy": 81 | if (is_null($destinationRecording)) 82 | throw new Exception("destination recording name not specified or is null", 503); 83 | $uri .= "/copy"; 84 | $postOBJ = array( 85 | 'destinationRecordingName' => $destinationRecording 86 | ); 87 | $result = $this->pestObject->post($uri, $postOBJ); 88 | break; 89 | default: 90 | throw new Exception("unknown action specified", 503); 91 | break; 92 | } 93 | break; 94 | } 95 | 96 | return $result; 97 | 98 | } catch (Exception $e) { 99 | $this->phpariObject->lasterror = $e->getMessage(); 100 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 101 | 102 | return FALSE; 103 | } 104 | } 105 | 106 | /** 107 | * This function is an alias to 'stored' - action 'show' or 'list' - will be deprecated in phpari 2.0 108 | * 109 | * @return mixed 110 | */ 111 | public function recording_list() 112 | { 113 | return $this->stored("show"); 114 | } 115 | 116 | /** 117 | * This function is an alias to 'stored' - action 'show' or 'list' - will be deprecated in phpari 2.0 118 | * 119 | * @return mixed 120 | */ 121 | public function recording_detail($recordingName = NULL) 122 | { 123 | return $this->stored("show", $recordingName); 124 | } 125 | 126 | /** 127 | * This function is an alias to 'stored' - action 'delete' - will be deprecated in phpari 2.0 128 | * 129 | * @return mixed 130 | */ 131 | public function delete_recording($recordingName = NULL) 132 | { 133 | return $this->stored("delete", $recordingName); 134 | } 135 | 136 | /** 137 | * This function is an alias to 'stored' - action 'copy' - will be deprecated in phpari 2.0 138 | * 139 | * @return mixed 140 | */ 141 | public function recording_stored_copy($recordingName = NULL, $destinationRecordingName = NULL) 142 | { 143 | return $this->stored("copy", $recordingName, $destinationRecordingName); 144 | } 145 | 146 | /** 147 | * Perform actions on live recordings. Start, Stop, Pause, Unpause, Mute, Unmute 148 | * 149 | * @param null $action 150 | * @param null $recordingName 151 | * 152 | * @return mixed 153 | */ 154 | public function live($action = NULL, $recordingName = NULL) 155 | { 156 | try { 157 | 158 | $uri = "/recordings/live"; 159 | 160 | if (is_null($action)) 161 | throw new Exception("action not specified or is null", 503); 162 | 163 | switch ($action) { 164 | case "show": 165 | $uri .= (!is_null($recordingName)) ? "/" . $recordingName : ""; 166 | $result = $this->pestObject->get($uri); 167 | break; 168 | default: 169 | if (is_null($recordingName)) 170 | throw new Exception("recording name not specified or is null", 503); 171 | 172 | $uri = "/recordings/live/" . $recordingName; 173 | $postData = array(); 174 | 175 | switch ($action) { 176 | case "start": 177 | throw new Exception("Starting a recording is done via channels interface - have you forgotten?", 503); 178 | break; 179 | case "stop": 180 | $uri .= "/stop"; 181 | $result = $this->pestObject->post($uri, $postData); 182 | break; 183 | case "discard": 184 | $result = $this->pestObject->delete($uri); 185 | break; 186 | case "pause": 187 | $uri .= "/pause"; 188 | $result = $this->pestObject->post($uri, $postData); 189 | break; 190 | case "unpause": 191 | $uri .= "/pause"; 192 | $result = $this->pestObject->delete($uri); 193 | break; 194 | case "mute": 195 | $uri .= "/mute"; 196 | $result = $this->pestObject->post($uri, $postData); 197 | break; 198 | case "unmute": 199 | $uri .= "/mute"; 200 | $result = $this->pestObject->delete($uri); 201 | break; 202 | default: 203 | throw new Exception("unknown action specified", 503); 204 | break; 205 | } 206 | break; 207 | } 208 | 209 | return $result; 210 | 211 | } catch (Exception $e) { 212 | $this->phpariObject->lasterror = $e->getMessage(); 213 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 214 | 215 | return FALSE; 216 | } 217 | } 218 | 219 | /** 220 | * This function is an alias to 'live' - action 'show' - will be deprecated in phpari 2.0 221 | * 222 | * @return mixed 223 | */ 224 | public function recordings_live_list($recordingName = NULL) 225 | { 226 | return $this->live("show", $recordingName); 227 | } 228 | 229 | /** 230 | * This function is an alias to 'live' - action 'discard' - will be deprecated in phpari 2.0 231 | * 232 | * @return mixed 233 | */ 234 | public function recordings_live_stop_n_discard($recordingName = NULL) 235 | { 236 | return $this->live("discard", $recordingName); 237 | } 238 | 239 | /** 240 | * This function is an alias to 'live' - action 'stop' - will be deprecated in phpari 2.0 241 | * 242 | * @return mixed 243 | */ 244 | public function recordings_live_stop_n_store($recordingName = NULL) 245 | { 246 | return $this->live("stop", $recordingName); 247 | } 248 | 249 | /** 250 | * This function is an alias to 'live' - action 'pause' - will be deprecated in phpari 2.0 251 | * 252 | * @return mixed 253 | */ 254 | public function recordings_live_pause($recordingName = NULL) 255 | { 256 | return $this->live("pause", $recordingName); 257 | } 258 | 259 | /** 260 | * This function is an alias to 'live' - action 'unpause' - will be deprecated in phpari 2.0 261 | * 262 | * @return mixed 263 | */ 264 | public function recordings_live_unpause($recordingName = NULL) 265 | { 266 | return $this->live("unpause", $recordingName); 267 | } 268 | 269 | /** 270 | * This function is an alias to 'live' - action 'mute' - will be deprecated in phpari 2.0 271 | * 272 | * @return mixed 273 | */ 274 | public function recordings_live_mute($recordingName = NULL) 275 | { 276 | return $this->live("mute", $recordingName); 277 | } 278 | 279 | /** 280 | * This function is an alias to 'live' - action 'unmute' - will be deprecated in phpari 2.0 281 | * 282 | * @return mixed 283 | */ 284 | public function recordings_live_unmute($recordingName = NULL) 285 | { 286 | return $this->live("unmute", $recordingName); 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /src/interfaces/sounds.php: -------------------------------------------------------------------------------- 1 | ariEndpoint)) 35 | throw new Exception("Missing PestObject or empty string", 503); 36 | 37 | $this->phpariObject = $connObject; 38 | $this->pestObject = $connObject->ariEndpoint; 39 | 40 | } catch (Exception $e) { 41 | die("Exception raised: " . $e->getMessage() . "\nFile: " . $e->getFile() . "\nLine: " . $e->getLine()); 42 | } 43 | } 44 | 45 | /** 46 | * GET /sounds 47 | * List all sounds. 48 | * 49 | * @param string $lang - Lookup sound for a specific language. 50 | * @param string $format - Lookup sound in a specific format. 51 | * @param string $soundID - The specific sound ID you would like to get details for 52 | * @return bool 53 | */ 54 | public function show($lang = NULL, $format = NULL, $soundID = NULL) 55 | { 56 | try { 57 | 58 | $uri = "/sounds"; 59 | $uri .= (!is_null($soundID))?"/" . $soundID:""; 60 | 61 | $getOBJ = array(); 62 | 63 | if (!is_null($lang)) 64 | $getOBJ['lang'] = $lang; 65 | 66 | if (!is_null($format)) 67 | $getOBJ['format'] = $format; 68 | 69 | $result = $this->pestObject->get($uri, $getOBJ); 70 | return $result; 71 | 72 | } catch (Exception $e) { 73 | $this->phpariObject->lasterror = $e->getMessage(); 74 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 75 | return false; 76 | } 77 | } 78 | 79 | /** 80 | * This function is an alias to 'show' - will be deprecated in phpari 2.0 81 | * 82 | * @return mixed 83 | */ 84 | public function sounds_list($lang = NULL, $format = NULL) 85 | { 86 | return $this->show($lang, $format); 87 | } 88 | 89 | /** 90 | * 91 | * GET /sounds/{soundId} 92 | * Get a sound's details. 93 | * 94 | * @param null $soundID 95 | * @return bool 96 | */ 97 | public function details($soundID = NULL) 98 | { 99 | try { 100 | 101 | if (is_null($soundID)) 102 | throw new Exception("Sound ID not provided or is null", 503); 103 | 104 | return $this->show(NULL, NULL, $soundID); 105 | 106 | } catch (Exception $e) { 107 | $this->phpariObject->lasterror = $e->getMessage(); 108 | $this->phpariObject->lasttrace = $e->getTraceAsString(); 109 | return false; 110 | } 111 | } 112 | 113 | 114 | /** 115 | * This function is an alias to 'details' - will be deprecated in phpari 2.0 116 | * 117 | * @return mixed 118 | */ 119 | public function sound_detail($soundID = NULL) 120 | { 121 | return $this->details($soundID); 122 | } 123 | } --------------------------------------------------------------------------------