David Podolsky > Switchvox-API > Switchvox::API

Download:
Switchvox-API-1.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.02   Source  

NAME ^

Switchvox::API - Perl interface to the Switchvox Extend API.

SYNOPSIS ^

This module provides a simple interface to interface with the Extend API on a Digium, Switchvox PBX. For more complete documentation on the entire Switchvox Extend API please visit http://developers.digium.com/switchvox. For more information on the Digium, Switchvox PBX product please visit the project home page at http://www.switchvox.com.

Note: The Switchvox::API object is a subclass of LWP::UserAgent so you can use all functionality of LWP::UserAgent.

An example of requesting information about two accounts (1106,1107) from the Switchvox PBX.

        my $api = new Switchvox::API(
                hostname => '192.168.0.50',
                username => 'admin',
                password => 'your_admin_password'
        );

        my $response = $api->api_request(
                method          => 'switchvox.extensions.getInfo',
                parameters      => 
                {
                        account_ids => 
                        [
                                { 'account_id' => [1106,1107] }
                        ],
                }
        );

        if($response->{api_status} eq 'success')
        {
                my $extensions = $response->{api_result}{response}[0]{result}[0]{extensions}[0]{extension};
                foreach my $extension (@$extensions)
                {
                        print "Extension:$extension->{number}, Full Name:$extension->{first_name} $extension->{last_name}\n";
                }
        }
        else
        {
                print "Encountered Errors:\n";
                foreach my $error ( @{$response->{api_errors}} )
                {
                        print "-Code:$error->{code},Message:$error->{message}\n";
                }
        }

AUTHOR ^

Written by David W. Podolsky <api at switchvox dot com>

Copyright (C) 2009 Digium, Inc

SEE ALSO ^

Switchvox::API::Request, Switchvox::API::Response, http://developers.digium.com/switchvox/

METHODS ^

new( %args )

Returns a new Switchvox::API object.

hostname

The hostname or IP address of the Switchvox PBX.

username

The admin name or the extension used for authentication with the Switchvox. If you use an extension you can only call user methods via the Extend API.

password

The admin password or extension password used for authentication.

api_request( %args )

Returns an Switchvox::API::Response object.

method

Name of the API method you want to call.

parameters

List of parameters to pass to the API.

syntax highlighting: