Cisco-IPPhone
view release on metacpan or search on metacpan
# Print the Menu Object to the Phone
print $mymenu->Content;
Content-Type: text/xml
<CiscoIPPhoneMenu>
<Title>My Title</Title>
<Prompt>My Prompt</Prompt>
<MenuItem>
<Name>Item1</Name>
<URL>http://www.mydomain.com</URL>
</MenuItem>
<MenuItem>
<Name>Item 2</Name>
<URL>http://www.mydomain.com</URL>
</MenuItem>
<SoftKeyItem>
<Name>Select</Name>
<URL>SoftKey:Select</URL>
<Position>1</Position>
</SoftKeyItem>
<SoftKeyItem>
<Name>Exit</Name>
<URL>SoftKey:Exit</URL>
<Position>2</Position>
</SoftKeyItem>
</CiscoIPPhoneMenu>
B< Example using Execute object to push messages to the phone>
#!/usr/bin/perl
# Mark Palmer - markpalmer@us.ibm.com
# Must use authentication when POSTING an object to a Cisco IPPhone.
# User should be a user in the global directory associated with the phone
# Can use this script to send messages to IPPhones
use Cisco::IPPhone;
use LWP::UserAgent;
use URI;
$ua = LWP::UserAgent->new;
$myexecute = new Cisco::IPPhone;
$SERVER = "192.168.250.17";
$IPPHONE = "192.168.250.7";
$USER = 'myname';
$PASSWORD = 'mypassword';
$POSTURL = "http://${IPPHONE}/CGI/Execute";
# URL that phone will fetch
$URL1 = "http://$SERVER/cgi-bin/nfl.cgi";
# Build Execute Object with up to 3 Execute Items
$myexecute->Execute;
$myexecute->AddExecuteItem( { ExecuteItem => "$URL1" });
my $xml = $myexecute->Content_Noheader;
# Translate non-alpha chars into hex
$xml = URI::Escape::uri_escape("$xml");
my $request = new HTTP::Request POST => "$POSTURL";
$request->authorization_basic($USER, $PASSWORD);
$request->content("XML=$xml"); # Phone requires parameter named XML
my $response = $ua->request($request); # Send the POST
if ($response->is_success) {
$result = $response->content;
if ($result =~ /CiscoIPPhoneError Number="(\d+)"/) {
$errno = $1;
if ($errno == 4) {
print "Authentication error\n";
} elsif ($errno == 3) {
print "Internal file error\n";
} elsif ($errno == 2) {
print "Error framing CiscoIPPhoneResponse object\n";
} elsif ($errno == 1) {
print "Error parsing CiscoIPPhoneExecute object\n";
} else {
print "Unknown Error\n";
print $result;
}
}
} else {
print "Failure: Unable to POST XML object to phone $IPPHONE\n";
print $response->status_line;
}
=head2 EXPORT
None by default.
=head1 AUTHOR
Mark Palmer, markpalmer@us.ibm.com, 7/13/2002
=head1 SEE ALSO
perl(1).
( run in 0.666 second using v1.01-cache-2.11-cpan-99c4e6809bf )