Retrieving the phone model using x-CiscoIPPhoneModelName

Version 1
    This document was generated from CDN thread

    Created by: Tom Barrand on 26-05-2009 04:28:37 PM
    Hi,
     
    Using IP Phone Services the documentation seems to mention that if you use x-CiscoIPPhoneModelName you get retrieve the phone model, e.g. CP-7960.
     
    Has anyone go an example of how you do this as I don't think it's that clear in the IP Phone Services Application Development Notes?
     
    Many Thanks
     
    Tom

    Subject: RE: Retrieving the phone model using x-CiscoIPPhoneModelName
    Replied by: Florian Endler on 26-05-2009 05:09:23 PM
    Hi Tom,
     
    with every GET request the phone sends some device specific information of itself to your server. Commonly you will find the following information in there:
     
    HTTP_X_CISCOIPPHONEMODELNAME
    HTTP_X_CISCOIPPHONESDKVERSION
    HTTP_X_CISCOIPPHONEDISPLAY
     
    which can give your application a pretty good idea of the capabilities of the requesting  phone. However, the way how to retrieve this information depends on the programming language you use.

    Cheers,
    Florian

    Subject: RE: Retrieving the phone model using x-CiscoIPPhoneModelName
    Replied by: David Staudt on 26-05-2009 06:13:05 PM
    As mentioned, these values are simply custom HTTP Headers added to the HTTP request packet by the phone.  Extracting a HTTP Header programmatically varies by which CGI technology/language you're using - here is a basic tutorial r.e. Java Servelets found with a quick web search: http://www.apl.jhu.edu/~hall/java/Servlet-Tutorial/

    Subject: PHP: SimpleXML: Retrieving the phone model using x-CiscoIPPhoneModelName
    Replied by: Brian Lavallee on 03-06-2009 01:07:37 AM
    Hi Tom,
     
    I used SimpleXML with PHP to accomplish this to choose the correct sized image to display.
     
    // Get the IP address of the requesting device.
    $ip=$_SERVER['REMOTE_ADDR'];
     
    // Retreive the device information from the phone.
    $rss =  simplexml_load_file('http://'.$ip.'/DeviceInformationX');
     
    // Extract only the digits from modelNumber.
    preg_match('{(\d+)}', $rss->modelNumber, $digits);
     
    // Determine the corrct size logo based on model number with switch.
    switch ($digits[1]) {
        case "7921": $logo = "Logo_176x140.png"; break;
        case "7940": $logo = "Logo_133x65.png"; break;
        case "7941": $logo = "Logo_298x144.png";break;
        // truncated...
    }

    Brian

    Subject: RE: PHP: SimpleXML: Retrieving the phone model using x-CiscoIPPhoneModelNam
    Replied by: Muhammad Sabir on 04-06-2009 08:23:36 PM
    Here is the Java code to do similar:
     
    String phoneModel=request.getHeader("x-ciscoipphonemodelname");

                boolean pngPhone=false;
                boolean txtPhone=false;
               
                if (phoneModel!=null){               
                    if (phoneModel.contains("7941")) pngPhone=true;
                    if (phoneModel.contains("7942")) pngPhone=true;
                    if (phoneModel.contains("7945")) pngPhone=true;
                    if (phoneModel.contains("7961")) pngPhone=true;
                    if (phoneModel.contains("7962")) pngPhone=true;
                    if (phoneModel.contains("7965")) pngPhone=true;
                    if (phoneModel.contains("7970")) pngPhone=true;
                    if (phoneModel.contains("7971")) pngPhone=true;
                    if (phoneModel.contains("7975")) pngPhone=true;
                    if (phoneModel.contains("Comm")) pngPhone=true;
                    if (pngPhones.contains(phoneType)) pngPhone=true;

                    if (phoneModel.contains("7905")) txtPhone=true;
                    if (phoneModel.contains("7912")) txtPhone=true;
                    if (txtPhones.contains(phoneType)) txtPhone=true;   
                }