Recently, the LC-Display of my phone broke. This means I can't use the built-in phonebook anymore and as I found out, I've become quite reliant on reading a phone number while keying it in. So I need a command line dialing facility just like my AVM Fritz!Box ISDN/VoIP adapter provides via its web interface. With the help of LWP and Sniffer::HTTP and HTTP::Request::FromTemplate, this was a job of five minutes:

#!/usr/bin/perl -w use strict; use lib 'lib'; use HTTP::Request::FromTemplate; use LWP::UserAgent; my $host = '192.168.1.103'; my $number = $ARGV[0]; my $time = time; my $ua = LWP::UserAgent->new(); my $template = do { local $/; <DATA> }; my $req = HTTP::Request::FromTemplate->new( template => \$template )-> +process({ host => $host, number => $number, time => $time }); print $req->as_string; my $res = $ua->request($req); print $res->as_string; __DATA__ POST http://[% host %]/cgi-bin/webcm HTTP/1.1 Host: [% host %] Referer: http://[% host %]/cgi-bin/webcm Content-Length: [% content_length %] Content-Type: application/x-www-form-urlencoded getpage=..%2Fhtml%2Fde%2Fmenus%2Fmenu2.html&errorpage=..%2Fhtml%2Fde%2 +Fmenus%2Fmenu2.html&var%3Alang=de&var%3Apagename=foncalls&var%3Aerror +pagename=foncalls&var%3Amenu=fon&var%3Apagemaster=&time%3Asettings%2F +time=[% time %]%2C-60&telcfg%3Asettings%2FUseClickToDial=1&telcfg%3As +ettings%2FDialPort=1&telcfg%3Acommand%2FDial=[% number %]

The astute reader will note the grand "security" scheme of the AVM Fritz!Box, which relies on the correct timestamp being submitted. I had first guessed that there would be some kind of magic cookie, but there is no password-cookie or anything. You just need to submit a recent-enough timestamp. Shocking. But then, you shouldn't use the Fritz!Box in a unsecured network anyway.

Update (on 2005-12-29): I found that I prefer to use the FireFox address bar to dial, using the following HTML

<html> <body> <form method="POST" action="http://fritzbox-ip/cgi-bin/webcm" target=" +_self" id="uiPostForm" name="uiPostForm"> <input type="hidden" name="login:command/password" value="soopah-s +ekret" id="uiPostPassword"> <input type="hidden" name="telcfg:settings/UseClickToDial" value=" +1" id="uiPostClickToDial"> <label for="telcfg:command/Dial"></label><input type="text" name=" +telcfg:command/Dial" value="" id="uiPostDial"> <input type="hidden" name="telcfg:settings/DialPort" value="1" id= +"uiPostDialPort"> <input type="hidden" name="getpage" value="../html/de/menus/menu2. +html" id="uiPostGetPage"> <input type="submit"> </form> </body>

I then added the dial keyword to FireFox and now can call from within FireFox.