This tutorial describes how to use the popular command line tool Wget to send XML files to the Extend API and get back the XML response.
If you don’t know what Wget is, the short answer is that it’s a simple commandline program that retrieves content from a web server. It can be found on almost all Linux distributions to be installed by default, comes with the new Mac OS X, and can be downloaded for Windows. If you want to learn more about Wget I suggest reading the Wikipedia Article.
To see if you have Wget installed, open a terminal and type
wget. If it says command not found then you need to install Wget. If itsays something like “Missing URL”, then you are all set.
First thing I am going to do is determine which Core method I want to call, and which parameters to use. For this example, I have decided I want to get an XML list of the voicemail and fax disk-usage for every extension on Switchvox.
After reading the documentation for switchvox.extensions.getVoicemailInfo I created an XML file named switchvox.extensions.getVoicemailInfo.xml:
extension ASC 50 1
Below is the full command you will type on the command line to connect to Switchvox and make this request. Don’t worry, I will explain each piece of it below:
wget --no-check-certificate --http-user=admin --http-password=YOUR_ADMIN_PASSWORD --header="Content-Type: text/xml" --post-file=switchvox.extensions.getVoicemailInfo.xml https://YOUR.PBX.IP/xml -O response.xml
- wget: Name of the command
- –no-check-certificate: All API requests uses HTTPs for security, and since I haven’t bought a signed SSL certificate I need to tell Wget to accept my unsigned certificate.
- –http-user=admin: The API uses digest authentication and this is how you tell Wget that you want your digest username to be admin.
- –http-pass=YOUR_ADMIN_PASSWORD: This is how you tell Wget what you want your digest password to be.
- –header=”Content-Type: text/xml”: Sends an HTTP header setting the content-type of the request to be text/xml
- –post-file=switchvox.extensions.getVoicemailInfo.xml: This tells Wget to use the POST method and send the contents of the file. This is the file we already created, and it should be in the same directory where you are running the Wget command.
- https://YOUR.PBX.IP/xml: Make sure to replace YOUR.PBX.IP with the IP or hostname of your Switchvox PBX.
- -O response.xml: Tells wget to write out the response of the request to the file named response.xml.
After you enter the full command, hit enter and execute the command you should see something similar to the following text fly by:
--13:35:01-- https://10.10.2.35/xml => `response.xml' Connecting to 10.10.2.35:443... connected. WARNING: Certificate verification error for 10.10.2.35: self signed certificate WARNING: certificate common name `dwp-dev35.switchvox.com' doesn't match requested host name `10.10.2.35'. HTTP request sent, awaiting response... 401 Authorization Required Connecting to 10.10.2.35:443... connected. WARNING: Certificate verification error for 10.10.2.35: self signed certificate WARNING: certificate common name `dwp-dev35.switchvox.com' doesn't match requested host name `10.10.2.35'. HTTP request sent, awaiting response... 200 OK Length: unspecified [text/xml] [ <=>; ] 2,716 --.--K/s 13:35:02 (29.43 MB/s) - `response.xml' saved 
This means the command executed successfully and our XML response is saved in response.xml in the same directory. Open the response.xml file and it should contain a list of all the extensions on your system and their voicemail and fax disk usage. Presto!