Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Define an Adhearsion PHP class for a REST HTTP connection
- class Adhearsion {
- public $url;
- public $username;
- public $password;
- function __construct($url, $username, $password) {
- $this->url = $url;
- $this->username = $username;
- $this->password = $password;
- }
- function invoke($method_name) {
- $json = json_encode(array_slice(func_get_args(), 1));
- $url = "$this->url/$method_name";
- return json_decode(http_post_data($url,
- $json,
- array("httpauth" => "$this->username:$this->password")));
- }
- }
- //Connect to the REST API of Adhearsion
- $ahn = new Adhearsion("localhost:5000", "jicksta", "roflcopterz");
- //Build an array of the options for calling
- $call_options = array ('channel' => 'SIP/303',
- 'context' => 'inbound',
- 'exten' => '1000',
- 'priority' => '1',
- 'async' => 'true',
- 'variable' => 'destination=304');
- //Invoke the Adhearsion originate method via an HTTP POST of a JSON object
- $ahn->invoke("originate", $call_options);
- ?>
Add Comment
Please, Sign In to add comment