Command-line mailbox downloader for Cisco Unity Connection

Starting in version 8 of Cisco Unity Connection, it is simple to write scripts to manipulate various aspects of Unity Connection, including user attributes (password/PIN, for example), messages, call handlers, and more, thanks to a new REST API. There are interfaces to both administrative and end-user functions. And not only scripts, but custom web portals or other web integrations. No SOAP and AXL required!

See Cisco’s DocWiki for the details:
And read the rest of this entry for a simple PHP script that connects to a user’s mailbox, dumps all the contents to a local folder, writes out a table of contents and gzips the whole thing up.
#!/usr/bin/php <?php if ($argc !== 3) {   fwrite(STDERR, "Usage: n");   fwrite(STDERR, "  php $argv[0] <mailbox> <password>n");   exit(1); } /* Web connection setup */ $baseURL = "https://YOUR-UCONN-SERVER-HERE:8443"; $auth = base64_encode("$argv[1]:$argv[2]"); $opts = array( 'http' => array ('method' => 'GET',                                 'timeout' => 4,                                 'header' => "Authorization: Basic $auth"),                'ssl' =>  array ('allow_self_signed' => TRUE)              ); $context = stream_context_create($opts); /* Get the user's folders list and counts */ $foldersURL = "$baseURL/vmrest/mailbox/folders"; if (!($result = file_get_contents($foldersURL, false, $context))) {   fwrite(STDERR, "Could not connect to Unity Connection for mailbox folders list.n");   exit(1); } $folders = simplexml_load_string($result); /* Now get contents of each mailbox that has messages */ $currtime = datestring(time()); $outputdir = $argv[1] . "_$currtime"; if (!mkdir($outputdir)) {   fwrite(STDERR, "Couldn't create directory $outputdirn");   exit(1); } $INDEX = fopen("$outputdir/index.txt", 'w'); $mainheader = "Mailbox of $argv[1] downloaded at $currtime"; fwrite($INDEX, "$mainheadern" . sprintf("%'=" . strlen($mainheader) . "snn", "")); foreach ($folders as $folder) {   if ($folder->MessageCount > 0) {     $folderheader = "Folder: $folder->DisplayName";     fwrite($INDEX, "$folderheadern" . sprintf("%'-" . strlen($folderheader) . "snn", ""));     $messagedir = $outputdir . "/" . $folder->DisplayName;     mkdir($messagedir);     $result = file_get_contents($baseURL . $folder->URI . "/messages", false, $context);     $xml = simplexml_load_string($result);     $counter = 1;     foreach ($xml->Message as $message) {       fwrite($INDEX, "$counter. Message from ". ($message->CallerId->CallerName == ""?"(no name listed)":$message->CallerId->CallerName));       fwrite($INDEX, " at " . ($message->CallerId->CallerNumber == ""?"(no number listed)":$message->CallerId->CallerNumber));       fwrite($INDEX, "n");       fwrite($INDEX, "Listened: " . $message->Read . "n");       fwrite($INDEX, "Length: " . $message->Duration/1000 . " secondsn");       fwrite($INDEX, "Timestamp:" . datestring($message->ArrivalTime/1000) . "n");       fwrite($INDEX, "Filename: ");       $filename = datestring($message->ArrivalTime/1000) . "_from_" . $message->CallerId->CallerNumber . ".wav";       fwrite($INDEX, "$filenamenn");       $innerResult = file_get_contents($baseURL . $message->URI, false, $context);       $messageContainer = simplexml_load_string($innerResult);       $audio = file_get_contents($baseURL . $messageContainer->Attachments->Attachment->URI, false, $context);       if (!file_put_contents("$messagedir/$filename", $audio, LOCK_EX))         fwrite(STDERR, "Error writing audio to file: $filenamen");       $counter++;     }     fwrite($INDEX, "n");   } } fclose($INDEX); $tarresult = system("tar czf $outputdir.tar.gz $outputdir"); if ($tarresult !== FALSE) {   system("rm -rf $outputdir"); } else {   fwrite(STDERR, "Unable to create tar.gz file, but the folder is still there.n"); } fwrite(STDERR, "Mailbox dump completed successfully.n"); exit(0); function datestring ($unixtime) {   return date('Y-m-d_H-i-s', $unixtime); } ?>

Google killing off Gizmo5

I just received this e-mail stating that Google is killing off the Gizmo5 VoIP service they acquired in 2009:

Gizmo5 is writing to let you know that we will no longer be providing service starting on April 3, 2011. A week from today, March 11, 2011, you will no longer be able to add credit to your account.

Although the standalone Gizmo5 client will no longer be available, we have since launched the ability to call phones from within Gmail at even more affordable rates.

Thank you,

The Gizmo5 Team

Before Google’s purchase of Gizmo5, the SIP provider had a unique relationship with GrandCentral and then Google Voice that allowed a SIP connection (incoming only) to a Google Voice number. Until FreeSWITCH and Asterisk provided updated Google Talk modules last fall, Gizmo5 was the only way to have a purely VoIP connection to Google Voice.