- Joined
- Aug 31, 2017
- Messages
- 65
- Reaction score
- 19
Hi everyone,
It's a continuation of the post created a few years ago.
https://www.3cx.com/community/threads/day-night-mode-visual-indication.41566/
A user had posted a php script to change the state of the LED on the phone and dial the number for the switch night and day.
I was able to activate the web server and modified the script so that it composes the desired code but when I try to launch the command "URL" from a key of a Yealink T46, it tells me the error code :
"File layout Error"
I do not know enough XML,... to know where the error come from.
Could someone please help me?
Here is the original code.
It's a continuation of the post created a few years ago.
https://www.3cx.com/community/threads/day-night-mode-visual-indication.41566/
A user had posted a php script to change the state of the LED on the phone and dial the number for the switch night and day.
I was able to activate the web server and modified the script so that it composes the desired code but when I try to launch the command "URL" from a key of a Yealink T46, it tells me the error code :
"File layout Error"
I do not know enough XML,... to know where the error come from.
Could someone please help me?
Here is the original code.
PHP:
<?php
$xml = "<"."?xml version=\"1.0\" encoding=\"ISO-8859-1\"?".">\n";
$xml.= "<3CXIPPhoneExecute Beep=\"no\">\n";
$xml.= " <ExecuteItem URI=\"Led:LINE15_GREEN=on\" />\n"; // light up "day" button LED
$xml.= " <ExecuteItem URI=\"Led:LINE16_GREEN=off\" />\n"; // switch off "night" button LED
$xml.= "</3CXIPPhoneExecute>\n";
// push LED on/off command to all desired phones (repeat this line for all phones you want to control)
push2phone ("ip.address.of.server", "ip.address.of.phone1", $xml);
push2phone ("ip.address.of.server", "ip.address.of.phone2", $xml);
// switch LED on/off and dial "day" shortdial for phone which calls this script
Echo "<"."?xml version=\"1.0\" encoding=\"ISO-8859-1\"?".">\n";
Echo "<3CXIPPhoneExecute Beep=\"no\">\n";
Echo " <ExecuteItem URI=\"Led:LINE15_GREEN=on\" />\n";
Echo " <ExecuteItem URI=\"Led:LINE16_GREEN=off\" />\n";
Echo " <ExecuteItem URI=\"Dial:*71\" />\n";
Echo "</3CXIPPhoneExecute>\n";
//-----------------------------------------------------------------
function push2phone ($server, $phone, $data)
{
$xml = "xml=".$data;
$post = "POST / HTTP/1.1\r\n";
$post.= "Host: $phone\r\n";
$post.= "Referer: $server\r\n";
$post.= "Connection: Keep-Alive\r\n";
$post.= "Content-Type: text/xml\r\n";
$post.= "Content-Length: ".strlen ($xml)."\r\n";
$post.= "\r\n";
$fp= @fsockopen ($phone, 80, $errno, $errstr, 0.01);
if ($fp)
{
fputs ($fp, $post.$xml);
fclose($fp);
}
}
?>