Category:HowTo
From SIPfoundry sipXecs IP PBX, The Open Source SIP PBX for Linux - Calivia
Sample Uses for the Polycom Microbrowser
By following these steps you can create a web page that allows the phones to get weather by US zip code using Yahoo (text only), stock quotes using apple.com and to dial customers as a click to navigate and dial function on the Polycom phones. This is Polycom and web server centric, and does not really rely on sipx for anything other than the entry for the microbrowser home page entry in sipxconfig.
This assumes the following:
You have a web server the phones can access that is configured and running php. Our suggestion is to use a different web server than your sipx system for this function. The server does not have to be on your network, just reachable by phones.
This also assumes the phones do not have to use a proxy server to get "out' on the Internet. If so, you must configure the phones for Proxy access.
First, test this on a single phone and enter the URL for the MicroBrowser>Home>for this phone as follows...
http://www.yourephpenabledserver.tld/PLCM/index.xhtml
(change the www.yourephpenabledserver.tld to whatever your accessible server is)
At your web server, create a directory called PLCM and then create and index.html page with the following inside... (creating index.html is optional, but recommended).
---BEGIN index.html--- <html> <body bgcolor="#FFFFFF"> </body> </html> ---END index.html---
This is just a blank page for index.html so it's not looked at and shows up "blank". Polycom web browsers like "xhtml" formatted pages, so here are three ways to use this.
Now create a index.xhtml page with this inside of it...
---BEGIN index.xhtml--- <html> <head> <title>Microbrowser Services page</title> </head> <body>
<a href="http://www.yourephpenabledserver.tld/PLCM/customers.xhtml">Customers</a>
<a href="http://www.yourephpenabledserver.tld/PLCM/weather.php">Weather</a>
<a href="http://www.yourephpenabledserver.tld/PLCM/stockquote.php">Stock Lookup</a>
</body> </html> ---END index.xhtml---
== Customize Weather Page Title and Zip Code: ==
copy the weather.php file into the PLCM directory. In the weather.php file, open with wordpad or plain text editor and change the lines before uploading.
$title = 'Advantrix Weather Fortcast'; // title will appear at the top of the page $default_zip = "27511";
to what you want
$title = 'Your_firm_name_here Weather Forecast'; // title will appear at the top of the page $default_zip = "your_five_digit_zip_code_here";
---BEGIN Weather.php--- <?php // Weather forcast for Polycom Phones // // Written by Peter Kaplan // // This is barely tested, use at your own risk. // It works with a standard 2.0 trixbox install. //
$title = 'Advantrix Weather Fortcast'; // title will appear at the top of the page
$default_zip = "27511";
echo "<html>\n<head>\n";
echo "<title>$title</title>\n</head>\n<body>\n";
if ($_GET[zipcode]=="")
$_GET[zipcode] = $default_zip;
if ($_GET[zipcode]) {
$handle = fopen( "http://weather.yahooapis.com/forecastrss?p=$_GET[zipcode]", "rb");
if ($handle == NULL) die("Bad Read");
$results = ;
while (!feof($handle)) {
$results .= fread($handle, 4096);
}
if ($results) {
/*
$city = extractBetweenDelimeters($results,"<City>","</City>");
$state = extractBetweenDelimeters($results,"<State>","</State>");
$temp = extractBetweenDelimeters($results,"<Temperature>","</Temperature>");
$humidity = extractBetweenDelimeters($results,"<Humidity>","</Humidity>");
$windspeed = extractBetweenDelimeters($results,"<WindSpeed>","</WindSpeed>");
$winddirection = extractBetweenDelimeters($results,"<WindDirection>","</WindDirection>");
$description = extractBetweenDelimeters($results,"<WeatherText>","</WeatherText>");
$time = extractBetweenDelimeters($results,"<Time>","</Time>");
*/
$title = extractBetweenDelimeters($results,"<title>","</title>");
$desc = extractBetweenDelimeters($results,"<![CDATA[","]]>");
$desc = extractBetweenDelimeters($results,".gif\" />
","(provided by The Weather Channel)
");
$desc = str_replace( "
", "
", $desc);
$page = "- \n";
$page.= "
- $title
- " . $desc . "
\n"; $page.= "
\n"; $page.= "
} fclose( $handle); echo $page; }echo "
"; echo "<form id=\"quote\" name=\"quote\" method=\"GET\" action=\"weather.php\">"; echo "Zipcode:<input type=\"text\" name=\"zipcode\" size=\"5\" value=\"$_GET[zipcode]\"/>"; echo "<input type=\"submit\" value=\"Submit\"/>"; echo "</form>"; echo "
";echo "</body>\n</html>";
function extractBetweenDelimeters($inputstr,$delimeterLeft,$delimeterRight) {
$posLeft = strpos($inputstr,$delimeterLeft)+strlen($delimeterLeft); $posRight = strpos($inputstr,$delimeterRight,$posLeft); return substr($inputstr,$posLeft,$posRight-$posLeft);
}
?> ---END weather.php---
Then load this with your PC web browser to test it.
If it works, then it will work in the phone.
Customize Stockquote page title:
In the stockquote.php file, open with wordpad or plain text editor and change the lines before uploading.
$title = $phone_system_name . ' Stock Quote'; // title will appear at the top of the page
to
$title = $phone_system_name . 'your_firm_name_here Stock Quote'; // title will appear at the top of the page
---BEGIN stockquote.php--- <?php // Stock Quote Generator for Polycom Phones // // Written by Peter Kaplan // // This is barely tested, use at your own risk. // It works with a standard 2.0 trixbox install. //
$title = $phone_system_name . ' Stock Quote'; // title will appear at the top of the page
echo "<html>\n<head>\n";
echo "<title>$title</title>\n</head>\n<body>\n";
if ($_GET[symbol]) {
$handle = fopen("http://wu.apple.com/fq/applewidgets/quote.asp?key=tHisIsApplewidgeTs&symbols=$_GET[symbol]", "r");
if ($handle == NULL) die("Bad Read");
$results = fread($handle, 4096);
fclose( $handle);
if ($results) {
$company = extractBetweenDelimeters($results,"<COMPANYNAME>","COMPANYNAME>");
$company = extractBetweenDelimeters($company,"<![CDATA[","]]>");
$symbol = extractBetweenDelimeters($results,"<SYMBOL>","</SYMBOL>");
$symbol = extractBetweenDelimeters($symbol,"<![CDATA[","]]>");
$exchange = extractBetweenDelimeters($results,"<EXCHANGE><![CDATA[","]]></EXCHANGE>");
$lasttrade = extractBetweenDelimeters($results,"<LASTTRADE>","</LASTTRADE>");
$change = extractBetweenDelimeters($results,"<CHANGE>","</CHANGE>");
$percentchange = extractBetweenDelimeters($results,"<PCTCHANGE>","</PCTCHANGE>");
$daylow = extractBetweenDelimeters($results,"<DAYLOW>","</DAYLOW>");
$dayhigh = extractBetweenDelimeters($results,"<DAYHIGH>","</DAYHIGH>");
$volume = extractBetweenDelimeters($results,"<VOLUME>","</VOLUME>");
}
$page = "- \n";
$page.= "
- Last Trade:" . $lasttrade . "
- Company: " . str_replace("&", "+", $company) . "
- Symbol: " . $symbol . "
- Exchange: " . $exchange . "
- Change: " . $change . "
- % Change: " . $percentchange . "
- Day Low: " . $daylow . "
- Day High: " . $dayhigh . "
- Volume: " . $volume . "
\n"; $page.= "
\n"; $page.= "
\n"; $page.= "
\n";
\n"; $page.= "
\n"; $page.= "
\n"; $page.= "
\n"; $page.= "
\n"; $page.= "
echo $page; }echo "
"; echo "<form id=\"quote\" name=\"quote\" method=\"GET\" action=\"stockquote.php\">"; echo "Symbol:<input type=\"text\" name=\"symbol\" size=\"5\" value=\"$_GET[symbol]\"/>"; echo "<input type=\"submit\" value=\"Submit\"/>"; echo "</form>"; echo "
";echo "</body>\n</html>";
function extractBetweenDelimeters($inputstr,$delimeterLeft,$delimeterRight) {
$posLeft = strpos($inputstr,$delimeterLeft)+strlen($delimeterLeft); $posRight = strpos($inputstr,$delimeterRight,$posLeft); return substr($inputstr,$posLeft,$posRight-$posLeft);
}
?> ---END stockquote.php---
Then load this with your PC web browser to test it.
If it works, then it will work in the phone.
Customize Phone Lists:
Beware putting this next page on an Internet web server, unless you have a way to control via ACL's what address ranges can load it, since it will expose your customer list and phone numbers to the Internet without any security. Realize you cannot load this in a normal web browser as readable, but if properly formatted, the example will allow you to select the "customers' page and click to dial the folks at Pingtel with the navigation buttons on the Polycom Phone.
In the respective Customers page you would create (customers.xhtml), paste in this text...
---BEGIN customers.xhtml---
<html>
<head>
<title>Customer Directory</title>
</head>
<body>
<a href="tel://17812290533">Pingtel (17812290533)</a>
<a href="tel://1234567">Customer 1 (1234567)</a>
</body> </html> ---END customers.xhtml---
You don't have to put the number in parentheses or include the parentheses at all for that matter, but since 2.2 firmware, you no longer see the "link reference" at the bottom of the browser window to see what it is going to dial, and sometimes you just want to have the number available for reference. You can then navigate to the customer and dial it via the microbrowser or at least reference it while on a call. Polycom does not support sip: dialing via the microbrowser yet. You should just enter the phone number in the format you want it to be dialed and let sipx dialing rules decide how it would get dialed. I have not tried using tel://(uri) dialing with it, but suspect if it were properly formatted, it would work (i.e. tel://user@domain or tel://user*isn, etc.). This is a simple naviagte and click phone dialer from the phone.
Pages in category "HowTo"
The following 12 pages are in this category, out of 12 total.
BH |
H cont. |
OS |
