Time Managers Services Tools Company
bSmart Communications

  API Methods 
  Web Integration 
       -Flash Code Example
 
Flash Code Example
This example uses the methods and properties of the Flash ActionScript XML object to do the following:
1) Construct an HTTP QueryString
2) Send the HTTP QueryString to iPing's notification platform server to request a notification
3) Load the server's response XML document
4) Parse the XML document to get status of transaction ("OK", "ERR"). The value of the element "pduType" holds the status of the transaction.

The code example below uses the Flash ActionScript XML (object).
XML is supported by Flash Player 5 and Flash Player 6. In Flash MX, the XML object has become a native object.

-------------------------------------------------------------------------------------
//submit button
submit.onRelease = function() {

   //Construct HTTP QueryString
   GENERAL_BASE_URL = "https://www.iping.com/services/iping.asp?";

   vUrl = GENERAL_BASE_URL;
   vUrl += "method_name=putnotification";
   vUrl += "&user_name=TestDriver"
   vUrl += "&password=12345";
   vUrl += "&ndt=1/1/2003";
   vUrl += "&ntz=-5;
   vUrl += "&notification_type=Ms.Reminder";
   vUrl += "&content_type=Text Message";
   vUrl += "&content_subtype=QuickPing";
   vUrl += "&msg_text_body=Hello and welcome to iPing";
   
   if (ckboxPhone.getValue()) // send phone call?
      {vUrl += "&pn=" + phone_number;}

   if (ckboxEmail.getValue()) // send email?
   {
      vUrl += "&email_to=" + email_address;
      vUrl += "&email_from=quickping@iping.com";
      vUrl += "&email_subject=QuickPing! Reminder";
      vUrl += "&email_template=eml_generic.xml";
      vUrl += "&email_body=Hello and welcome to iPing";
   }

   //You must use the constructor new XML() to create an instance
   //of the XML object before calling any of the methods
   //of the XML object.
   notificationXML = new XML();

   //Construct an XML object to hold the server's reply
   notificationReplyXML = new XML();

   // Set onLoad Function
   notificationReplyXML.onLoad = onNotificationReply;

   //Send QueryString to Server
   //Load Server's Response XML document
   //and put it in notificationReplyXML object
   notificationXML.sendAndLoad(vUrl, notificationReplyXML);

}


-------------------------------------------------------------------------------------
//Get Reply from Server
//This Call back function is executed
//after notificationReplyXML is loaded with response XML document
function onNotificationReply(){

   //---------Sample Success XML Reply-------------
   //<?xml version='1.0'?>
   //<bSmartXML version="1.0">
   //   <pduType value="OK">
   //   <data>
   //      <notification_id value="<unique_id>">
   //   </data>
   //</bSmartXML>

   //---------Sample Failure XML Reply-------------
   //<?xml version='1.0'?>
   //<bSmartXML version="1.0">
   //   <pduType value="ERR">
   //   <error_description value="invalid US/Canada phone number 1117551686">
   //   <data>
   //      invalid US/Canada phone number 1117551686
   //   </data>
   //</bSmartXML>

   // Get the first XML element
   bSmartXML = this.firstChild;

   pduType = "ERR"; // assume error
   bSmartXMLNodes = bSmartXML.childNodes;

   for (i=0; i<=bSmartXMLNodes.length; i++)
   {
      if (bSmartXMLNodes[i].nodeValue == null
      && bSmartXMLNodes[i].nodeName == "pduType")
      {
         pduType = bSmartXMLNodes[i].attributes.value;
       }

      if (bSmartXMLNodes[i].nodeValue == null
      && bSmartXMLNodes[i].nodeName == "data")
      {
         vDataNodes = bSmartXMLNodes[i].ChildNodes;
         notification_id = GetValue(vDataNodes, "notification_id");
      }
   }

   if (pduType == "OK")
       gotoAndStop("Success"); // goto Success frame in main Timeline.
   else
      error_description = bSmartXML.nextSibling.childNodes[2].attributes.value;

}

-------------------------------------------------------------------------------------






©1998-2007 iPing, Inc. All rights reserved.
Privacy policy | Terms of use | Contact us