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.


In reply to Use your AVM Fritz!Box for command-line dialing by Corion

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.