Using PHP for Cisco IP Phone Apps

One of the advantages that IP phones have is the ability to create custom applications that can perform any number of functions. PHP and other dynamic web development languages can be used to create a great deal of functionality. The following is a simple application that prints one of three quotes to the phone. PHP or another dynamic language could be used to query databases, websites, etc. for any kind of data you may want accessible from a phone.

The text below was saved as “quote.php” on a PHP enabled web server, and added as a standard XML app. Due to the layout of the blog, you are probably better off copying this into your favorite text editor.

<?php header(‘Content-type: text/xml’); ?> <!– Without this line, the phone will not parse this as XML. Must be the first line of the script –>
<CiscoIPPhoneText> <!– Puts text on the phone screen–>
<Title>Today’s quote is:</Title> <!– This displays on the top, over the main text area–>
<Prompt>Why do you ask?</Prompt> <!– This displays on the bottom, under the main text area–>
<Text> <!– This assigns the actual text on the phone–>

<!– The PHP function defines an array of quotes, and posts one to the text area–>
<?php
$quote = [“To be or not to be, that is the question”, “Everybody comes to Rick’s”, “Follow the white rabbit”];
$rnum = rand(0,2);
print($quote[$rnum]);
?>
</Text>
<SoftKeyItem> <!– Define a softkey. The ones here are the defaults, and the app doesn’t really need them.–>
<Name>Update</Name> <!– The name that displays–>
<URL>SoftKey:Update</URL> <!– The URL or an action–>
<Position>1</Position> <!– The softkey position–>
</SoftKeyItem>
<SoftKeyItem>
<Name>Exit</Name>
<URL>SoftKey:Exit</URL>
<Position>3</Position>
</SoftKeyItem>
</CiscoIPPhoneText>

The app is added to CUCM as an XML Service:

The app on a phone:

Also see: Cisco Unified IP Phone Services Application Development Notes, PHP books at Amazon.com


Comments

Using PHP for Cisco IP Phone Apps — 5 Comments

  1. Hi Peter,

    Thanks for you tutorial and it nice. I am implementing XML application for my Cisco Phone and I already implemented on my CUCM the xml script above, but on my ipphone always get the error message :
    XML Erro [4] : Parse error

    I also looking for the other stuff but still get the error message as I said before. Now I get the stuck to develop it.

    Could you please give me the step by step detail regarding pushing the xml script to CUCM ?

    If you don’t mind, please we continue this topic on the email.

    Thanks.
    Regards,
    Taufik

    • Taufik, are you sending the ‘Content-type: text/xml’ header?

      If you are, can you give me a quick description of how the app is supposed to work? Is the phone requesting the page, or are you trying to push it to the phone?

      • Hi Peter,

        Thanks for your reply.
        1. are you sending the ‘Content-type: text/xml’ header?
        Yes, I am. I already tried to copy the whole script and I named it rabbit.php

        2. can you give me a quick description of how the app is supposed to work? Is the phone requesting the page, or are you trying to push it to the phone?
        The phone is requesting the page when we push the services button on ip phone. Let me give some of explanation :
        I already built web server with XAMPP application and it running properly. The XML script (rabbit.php) can be accessed from another PC on the local network via web browser.
        I create a new service on CUCM and fill the URL address : http://192.168.1.17:8088/rabbit.php

        192.168.1.17 is my web server. But When I push the service button on ip phone, I got the error message : XML Erro [4] : Parse error.

        Need your advice.
        Could you please delete my first comment, because on the signature, I put my email or you can delete only my email on signature. 🙂

        Thank You.

          • Hi Peter,

            IF we access the XML file via web browser, the bowser will display all of XML code and I think it’s normal. But on the ip phone still getting error message.

            regards,
            Taufik

Leave a Reply

Your email address will not be published. Required fields are marked *