Cisco IPPhone 7965

Cisco Certified Network Associate (CCNA)
Cisco Certified Security Professional (CCSP)
Cisco Certified Internetwork Expert (CCIE)
Cisco Certified Design Professional (CCDP)
Cisco Certified Design Associate (CCDA)
Admin
Site Admin
Posts: 955
Joined: Thu Aug 23, 2007 10:35 am

Cisco IPPhone 7965

Postby Admin » Fri Feb 03, 2012 12:41 am

.NET

Code: Select all

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.XPath;
using System.Net;
using System.IO;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string ipAddress = "10.6.33.21";

            CiscoIPPhoneServices.CiscoIPPhoneMenu MyMenu = new CiscoIPPhoneServices.CiscoIPPhoneMenu("title", "Prompt");
            CiscoIPPhoneServices.CiscoIPPhoneText mytext = new CiscoIPPhoneServices.CiscoIPPhoneText("Test", "prompt", "test");

            HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create("http://" + ipAddress + "/CGI/Execute");
            webRequest.ProtocolVersion = new Version("1.0");

            //http://www.cisco.com/en/US/docs/voice_ip_comm/cuipph/all_models/xsi/7_0/english/programming/guide/xsi70uri.html
            //string sXML = "<CiscoIPPhoneExecute><ExecuteItem Priority=\"0\"URL=\"http://vm182/\"/></CiscoIPPhoneExecute>";
            //string sXML = "<CiscoIPPhoneExecute><ExecuteItem Priority=\"0\"URL=\"Play:chime.raw\"/></CiscoIPPhoneExecute>";
            //string sXML = "<CiscoIPPhoneExecute><ExecuteItem Priority=\"0\"URL=\"http://vm182/texter.xml\"/></CiscoIPPhoneExecute>";
            //string sXML = "<CiscoIPPhoneText><Title>The Boss's Phone</Title><Prompt>Choose Wisely</Prompt><Text>SR#24568</Text><SoftKeyItem><Name>I'm Scared</Name><URL>SoftKey:OK</URL><Position>1</Position></SoftKeyItem><SoftKeyItem><Name>Cancel</Name><URL>SoftKey:Cancel</URL><Position>4</Position></SoftKeyItem></CiscoIPPhoneText>";
            string sXML = "<CiscoIPPhoneExecute><ExecuteItem Priority=\"0\"URL=\"Dial:#18001234567\"/></CiscoIPPhoneExecute>";
            //string sXML = "<CiscoIPPhoneExecute><ExecuteItem URL=\"SendDigits:6185551212,,987654321,1234:1:Cisco/Dialer\"/></CiscoIPPhoneExecute>";
            webRequest.Method = "POST";

           
            string userNameAndPassword = "admin:cisco";
            byte[] bytes = System.Text.Encoding.ASCII.GetBytes(userNameAndPassword);
            string userNameAndPasswordInBase64 = Convert.ToBase64String(bytes);
            webRequest.Headers.Add("Authorization", "Basic " + userNameAndPasswordInBase64);

            //webRequest.Credentials = new NetworkCredential("admin", "cisco");
            sXML = "XML=" + System.Web.HttpUtility.UrlEncode(sXML); //Import System.web
               
            byte[] byteArray = Encoding.UTF8.GetBytes(sXML);
            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.ContentLength = byteArray.Length;
            Stream dataStream = webRequest.GetRequestStream();
            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();
            HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
            Stream resStream = response.GetResponseStream();

            string tempString = null;
           int    count      = 0;
            byte[]        buf = new byte[8192];
            StringBuilder sb  = new StringBuilder();
           do
           {
              // fill the buffer with data
              count = resStream.Read(buf, 0, buf.Length);

              // make sure we read some data
              if (count != 0)
              {
                 // translate from bytes to ASCII text
                 tempString = Encoding.ASCII.GetString(buf, 0, count);

                 // continue building the string
                 sb.Append(tempString);
              }
           }
           while (count > 0); // any more data to read?

        System.Diagnostics.Debug.WriteLine(sb.ToString());
            //System.Diagnostics.Debug.WriteLine(System.Text.ASCIIEncoding.UTF8.GetString(response));
        }
    }
}



Authentication URL is a HTTP request looking for "AUTHORIZED"

Admin
Site Admin
Posts: 955
Joined: Thu Aug 23, 2007 10:35 am

Re: Cisco IPPhone 7965

Postby Admin » Fri Feb 03, 2012 12:42 am

VB.net

Code: Select all

objSvrHTTP.open("GET", "http://" + IP + "/CGI/Screenshot", False, UserID, PIN)
objSvrHTTP.send()
ByteArr = objSvrHTTP.responseBody
Byte2Image()
End Sub

Private Sub Byte2Image()

' Converts image returned from phone in Byte array into bmp file

Try
If ByteArr.GetUpperBound(0) > 0 Then
ImageStream = New MemoryStream(ByteArr)
ScreenShot = Image.FromStream(ImageStream)
Else
ScreenShot = Nothing
End If
Catch ex As Exception
ScreenShot = Nothing
End Try
PBSCREEN.Image = ScreenShot
End Sub



http://buildbreaker.wordpress.com/2010/ ... -ip-phone/
http://search.cpan.org/~mrpalmer/Cisco- ... IPPhone.pm
http://blog.crowe.co.nz/archive/2008/10 ... ing-C.aspx


Return to “Cisco Certs”

Who is online

Users browsing this forum: No registered users and 1 guest