Cisco 79XX XML Push
NB This has only been tested with the SCCP image, not SIP.
If you want to Push an XML Object to a Cisco IP Phone, it first tries to authenticate your request against a Call Manager. If you don't have a Call Manager (e.g. you're using Asterisk), then you can use "<authenticationURL></authenticationURL>" in the SEP<MAC>.cnf.xml. The phone can then be directed to any web server which handles the authentication.
Data transferred:
1) The Push is done by posting a "CiscoIPPhoneExecute" with the URL of the Object you want to be loaded. The POSTing has to be directed to the phone at the URL "/CGI/Execute" and must use HTTP Basic Authentication.
2) The phone POSTs 'UserID', 'Password' and 'devicename'
3) The server answers 'ERROR', 'UN-AUTHORIZED' or 'AUTHORIZED' (ensure no headers sent and no extra characters. The phone will respond with a 'CiscoIPPhoneError Number="4"' if it receives anything extra.)
Now it's up to you, what your script answers according to UserID andPassword.
A simple authentication script, always allowing access, would be:
<?
php echo "AUTHORIZED";
?>
(NB This doesn't check UserID and Password) Also make sure that there are no extra characters, such as spaces, outside the <?php....?>.
An example to send an Execute Object to the phone, containing the URL you want to be pulled:
<?php
## This is an example of CiscoIPPhoneExecute as seen in the SDK
## Usage: Simply include in your php program and call the funtion
# using the parameters:
# $ip = IP of phone we're pushing to
# $uri = the URL or URI we want the phoneto execute
# $uid = the user id to authenticateagainst to the phone
# $pwd = the password to authenticate
### Author: alex@aiesec.uni-rostock.de, Oct. 2003
#
function push2phone($ip, $uri, $uid, $pwd)
{
$auth = base64_encode($uid.":".$pwd);
$xml = "<CiscoIPPhoneExecute><ExecuteItem Priority=\"0\"URL=\"".$uri."\"/></CiscoIPPhoneExecute>";
$xml = "XML=".urlencode($xml);
$post = "POST /CGI/Execute HTTP/1.0\r\n";
$post .= "Host: $ip\r\n";
$post .= "Authorization: Basic $auth\r\n";
$post .= "Connection: close\r\n";
$post .= "Content-Type: application/x-www-form-urlencoded\r\n";
$post .= "Content-Length: ".strlen($xml)."\r\n\r\n";
$fp = fsockopen ( $ip, 80, $errno, $errstr, 30);
if(!$fp){ echo "$errstr ($errno)<br>\n"; }
else
{
fputs($fp, $post.$xml);
flush();
while (!feof($fp))
{
$response .= fgets($fp, 128);
flush();
}
}
return $response;
}
##############################
$ip = "your.CISCO.phone.here";
$uri = "http://your.web.server.here/hello_world.php";
$uid = "test";
$pwd = "test";
echo push2phone($ip, $uri, $uid, $pwd);
?>
If you want to Push an XML Object to a Cisco IP Phone, it first tries to authenticate your request against a Call Manager. If you don't have a Call Manager (e.g. you're using Asterisk), then you can use "<authenticationURL></authenticationURL>" in the SEP<MAC>.cnf.xml. The phone can then be directed to any web server which handles the authentication.
Data transferred:
1) The Push is done by posting a "CiscoIPPhoneExecute" with the URL of the Object you want to be loaded. The POSTing has to be directed to the phone at the URL "/CGI/Execute" and must use HTTP Basic Authentication.
2) The phone POSTs 'UserID', 'Password' and 'devicename'
3) The server answers 'ERROR', 'UN-AUTHORIZED' or 'AUTHORIZED' (ensure no headers sent and no extra characters. The phone will respond with a 'CiscoIPPhoneError Number="4"' if it receives anything extra.)
Now it's up to you, what your script answers according to UserID andPassword.
A simple authentication script, always allowing access, would be:
<?
php echo "AUTHORIZED";
?>
(NB This doesn't check UserID and Password) Also make sure that there are no extra characters, such as spaces, outside the <?php....?>.
An example to send an Execute Object to the phone, containing the URL you want to be pulled:
<?php
## This is an example of CiscoIPPhoneExecute as seen in the SDK
## Usage: Simply include in your php program and call the funtion
# using the parameters:
# $ip = IP of phone we're pushing to
# $uri = the URL or URI we want the phoneto execute
# $uid = the user id to authenticateagainst to the phone
# $pwd = the password to authenticate
### Author: alex@aiesec.uni-rostock.de, Oct. 2003
#
function push2phone($ip, $uri, $uid, $pwd)
{
$auth = base64_encode($uid.":".$pwd);
$xml = "<CiscoIPPhoneExecute><ExecuteItem Priority=\"0\"URL=\"".$uri."\"/></CiscoIPPhoneExecute>";
$xml = "XML=".urlencode($xml);
$post = "POST /CGI/Execute HTTP/1.0\r\n";
$post .= "Host: $ip\r\n";
$post .= "Authorization: Basic $auth\r\n";
$post .= "Connection: close\r\n";
$post .= "Content-Type: application/x-www-form-urlencoded\r\n";
$post .= "Content-Length: ".strlen($xml)."\r\n\r\n";
$fp = fsockopen ( $ip, 80, $errno, $errstr, 30);
if(!$fp){ echo "$errstr ($errno)<br>\n"; }
else
{
fputs($fp, $post.$xml);
flush();
while (!feof($fp))
{
$response .= fgets($fp, 128);
flush();
}
}
return $response;
}
##############################
$ip = "your.CISCO.phone.here";
$uri = "http://your.web.server.here/hello_world.php";
$uid = "test";
$pwd = "test";
echo push2phone($ip, $uri, $uid, $pwd);
?>

Comments
333Dialing in from Cisco 7970 SIP phone and pushing XML to it
<br>
I have a Cisco 7970 phone with SIP firmware 8-3-3SR2S that is registered with Asterisk 1.4 , and I am trying to be able to make Asterisk push XML content to a phone when it dials a specific extension.
<br><br>
I have a problem pushing the XML to the phone, and I have made a post about it here : http://forums.digium.com/viewtopic.php?p=62069#62069
<br><br>
Since it is rather long, I would not repost it here, but I am hoping someone could enlighten me on the issue
<br>
Thanks!
333Works with SIP image in 7970
333Works with SIP image in 7941
333Any way to use XML services with 79xx and Covad VOIP
We're using Covad's hosted VOIP service (formerly Gobeam) and have a bunch of Cisco 7940's and 7960's. Is there a way to push our own XML services or upload xml logo files to these phones if we don't have a call manager or asterisk interface? I have the individual IP addresses of each phone if that helps.
333can't wirk with sip