Please note: These WebEx forums have replaced the earlier site forums. All the previous threads and posts have been replicated here, and if you subscribed to the previous forums, please re-subscribe. Thank you.
« Back to Scheduling Meetings

PHP wrappers for attendee Registration

Combination View Flat View Tree View
Threads [ Previous | Next ]
Here is a headstart for any of you using php.... I use my own registration site, which is setup (will be setup) to register attendees for WebEx webinars.  Code is not fully tested, but a darn good template....

1) file name: xmlParser2

<?php
function GetXMLTree ($xmldata)
{
 // we want to know if an error occurs
 ini_set ('track_errors', '1');
 $xmlreaderror = false;
 $parser = xml_parser_create ('ISO-8859-1');
 xml_parser_set_option ($parser, XML_OPTION_SKIP_WHITE, 1);
 xml_parser_set_option ($parser, XML_OPTION_CASE_FOLDING, 0);
 if (!xml_parse_into_struct ($parser, $xmldata, $vals, $index)) {
  $xmlreaderror = true;
  echo "error";
 }
 xml_parser_free ($parser);
 if (!$xmlreaderror) {
  $result = array ();
  $i = 0;
  if (isset ($vals [$i]['attributes']))
   foreach (array_keys ($vals [$i]['attributes']) as $attkey)
   $attributes [$attkey] = $vals [$i]['attributes'][$attkey];
  $result [$vals [$i]['tag']] = array_merge ($attributes, GetChildren ($vals, $i, 'open'));
 }
 ini_set ('track_errors', '0');
 return $result;
}
function GetChildren ($vals, &$i, $type)
{
 if ($type == 'complete') {
  if (isset ($vals [$i]['value']))
   return ($vals [$i]['value']);
  else
   return '';
 }
 $children = array (); // Contains node data
 /* Loop through children */
 while ($vals [++$i]['type'] != 'close') {
  $type = $vals [$i]['type'];
  // first check if we already have one and need to create an array
  if (isset ($children [$vals [$i]['tag']])) {
   if (is_array ($children [$vals [$i]['tag']])) {
    $temp = array_keys ($children [$vals [$i]['tag']]);
    // there is one of these things already and it is itself an array
    if (is_string ($temp [0])) {
     $a = $children [$vals [$i]['tag']];
     unset ($children [$vals [$i]['tag']]);
     $children [$vals [$i]['tag']][0] = $a;
    }
   } else {
    $a = $children [$vals [$i]['tag']];
    unset ($children [$vals [$i]['tag']]);
    $children [$vals [$i]['tag']][0] = $a;
   }
   $children [$vals [$i]['tag']][] = GetChildren ($vals, $i, $type);
  } else
   $children [$vals [$i]['tag']] = GetChildren ($vals, $i, $type);
  // I don't think I need attributes but this is how I would do them:
  if (isset ($vals [$i]['attributes'])) {
   $attributes = array ();
   foreach (array_keys ($vals [$i]['attributes']) as $attkey)
   $attributes [$attkey] = $vals [$i]['attributes'][$attkey];
   // now check: do we already have an array or a value?
   if (isset ($children [$vals [$i]['tag']])) {
    // case where there is an attribute but no value, a complete with an attribute in other words
    if ($children [$vals [$i]['tag']] == '') {
     unset ($children [$vals [$i]['tag']]);
     $children [$vals [$i]['tag']] = $attributes;
    }
    // case where there is an array of identical items with attributes
    elseif (is_array ($children [$vals [$i]['tag']])) {
     $index = count ($children [$vals [$i]['tag']]) - 1;
     // probably also have to check here whether the individual item is also an array or not or what... all a bit messy
     if ($children [$vals [$i]['tag']][$index] == '') {
      unset ($children [$vals [$i]['tag']][$index]);
      $children [$vals [$i]['tag']][$index] = $attributes;
     }
     $children [$vals [$i]['tag']][$index] = array_merge ($children [$vals [$i]['tag']][$index], $attributes);
    } else {
     $value = $children [$vals [$i]['tag']];
     unset ($children [$vals [$i]['tag']]);
     $children [$vals [$i]['tag']]['value'] = $value;
     $children [$vals [$i]['tag']] = array_merge ($children [$vals [$i]['tag']], $attributes);
    }
   } else
    $children [$vals [$i]['tag']] = $attributes;
  }
 }
 return $children;
}

?>
 
2)  filename: common.php
 
<?
require_once('xmlParser2.php');
class xmlCommon {

 
 // Specify WebEx site and port
    var $XML_SITE="hotmix.webex.com";
    var $XML_PORT="80";
 var  $url= "http://xxx.webex.com/WBXService/XMLService";
    function XML_Header()
 {
  // Set calling user information
  $d["SID"] = "12345";
  $d["UID"] = "xxx"; // WebEx username
  $d["PWD"] = "xxx";
  $d["PID"] = "xxx";
   
  
  $XML_Header="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
  $XML_Header.="<serv:message xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ";
  $XML_Header.="xmlns:serv=\"http://www.webex.com/schemas/2002/06/service\">";
  $XML_Header.="<header>";
  $XML_Header.="<securityContext>";  
  $XML_Header.="<webExID>{$d["UID"]}</webExID>";
  $XML_Header.="{$d["PWD"]}";   
  $XML_Header.="<siteID>{$d["SID"]}</siteID>";    
  $XML_Header.="{$d["PID"]}";  
  $XML_Header.="</securityContext>"; 
  $XML_Header.="</header>";
  $XML_Header.="<body>";
  return $XML_Header;
 }
  
 function XML_Footer()
 {
  $XML_Footer="</body>";
  $XML_Footer.="</serv:message>";
  return  $XML_Footer;
 }
 
 
 
}
 
 #--------------------------------------------------------------------------------------------------------------------------------------------------------
 #--------------------------------------------------------------------------------------------------------------------------------------------------------
 function getResponse($XML_RequestDoc, $URL, $Port)
        {
          
    //  Strip http:// from the URL if present
          $URL = ereg_replace("^http://", "", $URL);
   //  Separate into Host and URI
   $Host = substr($URL, 0, strpos($URL, "/"));
   $URI = strstr($URL, "/");
   
  
   $reqBody = $XML_RequestDoc;
   $ContentLength = strlen($reqBody);
  
           
            $header[] =  "POST $URI HTTP/1.0";
      $header[] = "Host: $Host";
   $header[] = "User-Agent: PostIt";
            $header[] = "Content-type: application/x-www-form-urlencoded";          
            $header[] = "Content-Length: $ContentLength\n";
            #$header[] = "Cache-Control: no-cache";
            #$header[] = "Connection: close \r\n";
            $header[] = $reqBody;
  
   
            $ch = curl_init();
            //Disable certificate check.
            // uncomment the next line if you get curl error 60: error setting certificate verify locations
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
            // uncommenting the next line is most likely not necessary in case of error 60
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
            //-------------------------
            //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
            //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
            //curl_setopt($ch, CURLOPT_CAINFO, "c:/ca-bundle.crt");
            //-------------------------
            curl_setopt($ch, CURLOPT_URL,$URL);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_TIMEOUT, 4);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST,'POST');
            curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
           
            $data = curl_exec($ch);       
            if (curl_errno($ch)) {
                print curl_error($ch);
            } else {
              
               return $data;
            }
        }
 #--------------------------------------------------------------------------------------------------------------------------------------------------------
 #--------------------------------------------------------------------------------------------------------------------------------------------------------
?>
 
3) filename: operations.php
 
<?
 include('common.php');
 
 
 
 
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
 function GetTrainingSession($MeetingID)
 {
  $xmlCommon = new xmlCommon();
  $XML_Header = $xmlCommon->XML_Header();
  $XML_Footer = $xmlCommon->XML_Footer();
  $URL= $xmlCommon->url;
  $XML_PORT= $xmlCommon->XML_PORT;
  
  $XMLBody.="<bodyContent xsi:type=\"java:com.webex.service.binding.training.GetTrainingSession\"> ";
  $XMLBody.= "<sessionKey>".$MeetingID."</sessionKey>";
  $XMLBody.="</bodyContent>";
  
  $XML = $XML_Header. $XMLBody. $XML_Footer;
  
  $Response =  getResponse($XML,$URL,$XML_PORT);
   $Results = GetXMLTree ($Response);
 
   $Success = $Results["serv:message"]["serv:header"]["serv:response"]["serv:result"];
   if ($Success == 'SUCCESS')
   {
  
     $StartDate =  $Results["serv:message"]["serv:body"]["serv:bodyContent"]["sess:schedule"]['sess:startDate'];  
     $StartTime = substr( $StartDate,-8);
     $StartHr = substr( $StartTime,0,2);
     $StartRestTime =  substr($StartTime,2,3);
     $TimeSuffix = 'am';
    
     if ($StartHr > 12)
     {
       $TimeSuffix = 'pm';
     $StartHr = $StartHr - 12;
     }
      if ($StartHr == 0)
     {
       $TimeSuffix = 'am';
     $StartHr =  12;
     }
    
     $NewStartTime = $StartHr.$StartRestTime.' '. $TimeSuffix;
     $NewStartDate = substr($StartDate,0,11).$NewStartTime;
   
    
     $TZ =  $Results["serv:message"]["serv:body"]["serv:bodyContent"]["sess:schedule"]['sess:timeZone'];   
    $Duration = $Results["serv:message"]["serv:body"]["serv:bodyContent"]["sess:schedule"]['sess:duration']; 
    $Topic = $Results["serv:message"]["serv:body"]["serv:bodyContent"]["train:metaData"]['sess:confName'];   
    $agenda = $Results["serv:message"]["serv:body"]["serv:bodyContent"]["train:metaData"]['train:agenda'];
    if ($agenda == '') $agenda = 'TBD';   
    $description = $Results["serv:message"]["serv:body"]["serv:bodyContent"]["train:metaData"]['train:description'];   
     if ($description == '') $description = 'Not specified';
    $EventID = $Results["serv:message"]["serv:body"]["serv:bodyContent"]["train:eventID"];   
    $Pwd = $Results["serv:message"]["serv:body"]["serv:bodyContent"]["sess:accessControl"]['sess:sessionPassword'];
    if ($Pwd == '') $Pwd = 'This session does not require a password';   
   $return = array('Success' => 1, 'Start Date' => $NewStartDate, 'TZ' =>  $TZ, 'Duration' => $Duration,
            'Topic' =>  $Topic, 'agenda' =>  $agenda, 'description' => $description, 'eventid' => $EventID , 'pwd' => $Pwd);
   }
   else
   {
     $Reason = $Results["serv:message"]["serv:header"]["serv:response"]["serv:reason"];
   $return = array('Success' => 0, 'Start Date' => '', 'TZ' =>  '', 'Duration' => '',  'Topic' =>  '', 'agenda' =>  '', 'description' => $Reason, 'eventid' => '' , 'pwd' => '');
  
  }
         
  return  $return;
 }
 
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 function GetEventSession($MeetingID)
 {
  $xmlCommon = new xmlCommon();
  $XML_Header = $xmlCommon->XML_Header();
  $XML_Footer = $xmlCommon->XML_Footer();
  $URL= $xmlCommon->url;
  $XML_PORT= $xmlCommon->XML_PORT;
  
  $XMLBody.="<bodyContent xsi:type=\"java:com.webex.service.binding.event.GetEvent\"> ";
  $XMLBody.= "<sessionKey>".$MeetingID."</sessionKey>";
  $XMLBody.="</bodyContent>";
  
  $XML = $XML_Header. $XMLBody. $XML_Footer;
  
  $Response =  getResponse($XML,$URL,$XML_PORT);
   $Results = GetXMLTree ($Response);
 
   $Success = $Results["serv:message"]["serv:header"]["serv:response"]["serv:result"];
   if ($Success == 'SUCCESS')
   {
  
     $StartDate =  $Results["serv:message"]["serv:body"]["serv:bodyContent"]["event:schedule"]['event:startDate'];  
     $StartTime = substr( $StartDate,-8);
     $StartHr = substr( $StartTime,0,2);
     $StartRestTime =  substr($StartTime,2,3);
     $TimeSuffix = 'am';
    
     if ($StartHr > 12)
     {
       $TimeSuffix = 'pm';
     $StartHr = $StartHr - 12;
     }
      if ($StartHr == 0)
     {
       $TimeSuffix = 'am';
     $StartHr =  12;
     }
    
     $NewStartTime = $StartHr.$StartRestTime.' '. $TimeSuffix;
     $NewStartDate = substr($StartDate,0,11).$NewStartTime;
   
    
     $TZ =  $Results["serv:message"]["serv:body"]["serv:bodyContent"]["event:schedule"]['event:timeZoneID'];  
     switch ($TZ )
    {
    case 2:
       $TZ = "GMT-10:00, Hawaii (Honolulu)";
      break; 
    case 3:
      $TZ = "GMT-09:00, Alaska (Anchorage)";
      break;
    case 4:
      $TZ = "GMT-08:00, Pacific (San Jose)";
      break;
    case 5:
      $TZ = "GMT-07:00, Mountain (Arizona)";
      break;
    case 6:
      $TZ = "GMT-07:00, Mountain (Denver)";
      break;
    case 7:
      $TZ = "GMT-06:00, Central (Chicago)";
      break;
    case 11:
      $TZ = "GMT-05:00, Eastern (New York)";
      break;
    default:
      $TZ = "";     
    }
   
      
    $Duration = $Results["serv:message"]["serv:body"]["serv:bodyContent"]["event:schedule"]['event:duration']; 
    $SessionName = $Results["serv:message"]["serv:body"]["serv:bodyContent"]["event:metaData"]['event:sessionName'];   
      
    $description = $Results["serv:message"]["serv:body"]["serv:bodyContent"]["event:metaData"]['event:description'];   
     if ($description == '') $description = 'Not specified';
    $EventID = $Results["serv:message"]["serv:body"]["serv:bodyContent"]["event:eventID"];   
    $Pwd = $Results["serv:message"]["serv:body"]["serv:bodyContent"]["event:accessControl"]['event:sessionPassword'];
    if ($Pwd == '') $Pwd = 'This session does not require a password';   
   $return = array('Success' => 1, 'Start Date' => $NewStartDate, 'TZ' =>  $TZ, 'Duration' => $Duration,
            'Session Name' =>  $SessionName,  'description' => $description, 'eventid' => $EventID , 'pwd' => $Pwd);
   }
   else
   {
     $Reason = $Results["serv:message"]["serv:header"]["serv:response"]["serv:reason"];
   $return = array('Success' => 0, 'Start Date' => '', 'TZ' =>  '', 'Duration' => '',  'Topic' =>  '',  'description' => $Reason, 'eventid' => '' , 'pwd' => '');
  
  }
   
  return  $return;
 }
 
#-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 
 
 function RegisterMeetingAttendee($MeetingID, $email, $name, $title, $company, $city, $state, $Country)
 {
  $xmlCommon = new xmlCommon();
  $XML_Header = $xmlCommon->XML_Header();
  $XML_Footer = $xmlCommon->XML_Footer();
  $URL= $xmlCommon->url;
  $XML_PORT= $xmlCommon->XML_PORT;
  
  $XMLBody.="<bodyContent xsi:type=\"java:com.webex.service.binding.attendee.CreateMeetingAttendee\"> ";
  $XMLBody.= "";
  $XMLBody.= "<name>".$name."</name>";
  $XMLBody.= "<title>".$title."</title>";
  $XMLBody.= "<company>".$company."</company>";
  $XMLBody.= "<address>";
   $XMLBody.= "<addressType>PERSONAL</addressType>";
   $XMLBody.= "<city>".$city."</city>";
   $XMLBody.= "<state>".$state."</state>";
   $XMLBody.= "<country>".$Country."</country>";
  $XMLBody.= "</address>";
  $XMLBody.= "<email>".$email."</email>";
  $XMLBody.= "<notes>Registered via API</notes>";
  $XMLBody.= "<type>VISITOR</type>";
  $XMLBody.= "";
  $XMLBody.= "<joinStatus>REGISTER</joinStatus>";
  $XMLBody.= "<role>ATTENDEE</role>";
  $XMLBody.= "<emailInvitations>false</emailInvitations>";
  $XMLBody.= "<sessionKey>".$MeetingID."</sessionKey>"; 
  $XMLBody.="</bodyContent>";
  $XML = $XML_Header. $XMLBody. $XML_Footer;
  
  $Response =  getResponse($XML,$URL,$XML_PORT);
   $Results = GetXMLTree ($Response);
 
   $Success = $Results["serv:message"]["serv:header"]["serv:response"]["serv:result"];
   $AttID =  $Results["serv:message"]["serv:body"]["serv:bodyContent"]["att:attendeeId"];
   $Reason = $Results["serv:message"]["serv:header"]["serv:response"]["serv:reason"];
 
  if ($Success == 'SUCCESS')
   $Successful = 1;
  else
   $Successful = 0;
   
  $answer = array('success' => $Successful, 'attendeeID' => $AttID, 'reason' =>  $Reason) ;
  return  $answer;
 }
 
 
 function LstMeetingAttendee($MeetingID, $AttendeeID)
 {
  $xmlCommon = new xmlCommon();
  $XML_Header = $xmlCommon->XML_Header();
  $XML_Footer = $xmlCommon->XML_Footer();
  $URL= $xmlCommon->url;
  $XML_PORT= $xmlCommon->XML_PORT;
  
  $XMLBody.="<bodyContent xsi:type=\"java:com.webex.service.binding.attendee.LstMeetingAttendee\"> ";  
  $XMLBody.= "<sessionKey>".$MeetingID."</sessionKey>"; 
   $XMLBody.="</bodyContent>";
  $XML = $XML_Header. $XMLBody. $XML_Footer;
  
  $Response =  getResponse($XML,$URL,$XML_PORT);
  $Results = GetXMLTree ($Response);
 
   $Success = $Results["serv:message"]["serv:header"]["serv:response"]["serv:result"];
   $AttendeeArray =   $Results["serv:message"]["serv:body"]["serv:bodyContent"]["att:attendee"];
   $PersonArray;
   foreach ($AttendeeArray as $key => $value)
      $PersonArray[] = array('RegID' => $value['att:registerID'], 'AttID' => $value['att:attendeeId']); 
  $RegID = 0;
  
  foreach ($PersonArray as $value)
  {
   if ($value['AttID'] == $AttendeeID)
    $RegID  = $value['RegID'] ;
  }
  
  
   $Reason = $Results["serv:message"]["serv:header"]["serv:response"]["serv:reason"];
 
  if ($Success == 'SUCCESS')
   $Successful = 1;
  else
   $Successful = 0;
  
  $answer = array('success' => $Successful, 'RegID' => $RegID, 'reason' =>  $Reason) ;
  return  $answer;
 }
 
 
?>
 

An update to function RegisterMeetingAttendee

You can totally skip the 2 call method of 1) createMeetingAttendee then RegisterMeetingAttendee to register someone.  The entire registration process can be done with the createMeetingAttendee call... Something I didn't notice last week, this also returns the RegID.  The code below has now been updated to return the regID as well.
 
function RegisterMeetingAttendee($MeetingID, $email, $name, $title, $company, $city, $state, $Country)
 {
  $xmlCommon = new xmlCommon();
  $XML_Header = $xmlCommon->XML_Header();
  $XML_Footer = $xmlCommon->XML_Footer();
  $URL= $xmlCommon->url;
  $XML_PORT= $xmlCommon->XML_PORT;
  
  $XMLBody.="<bodyContent xsi:type=\"java:com.webex.service.binding.attendee.CreateMeetingAttendee\"> ";
  $XMLBody.= "";
  $XMLBody.= "<name>".$name."</name>";
  $XMLBody.= "<title>".$title."</title>";
  $XMLBody.= "<company>".$company."</company>";
  $XMLBody.= "<address>";
   $XMLBody.= "<addressType>PERSONAL</addressType>";
   $XMLBody.= "<city>".$city."</city>";
   $XMLBody.= "<state>".$state."</state>";
   $XMLBody.= "<country>".$Country."</country>";
  $XMLBody.= "</address>";
  $XMLBody.= "<email>".$email."</email>";
  $XMLBody.= "<notes>Registered via API</notes>";
  $XMLBody.= "<type>VISITOR</type>";
  $XMLBody.= "";
  $XMLBody.= "<joinStatus>REGISTER</joinStatus>";
  $XMLBody.= "<role>ATTENDEE</role>";
  $XMLBody.= "<emailInvitations>false</emailInvitations>";
  $XMLBody.= "<sessionKey>".$MeetingID."</sessionKey>"; 
  $XMLBody.="</bodyContent>";
  $XML = $XML_Header. $XMLBody. $XML_Footer;
  
  $Response =  getResponse($XML,$URL,$XML_PORT);
   $Results = GetXMLTree ($Response);
 
   $Success = $Results["serv:message"]["serv:header"]["serv:response"]["serv:result"];
   $AttID =  $Results["serv:message"]["serv:body"]["serv:bodyContent"]["att:attendeeId"];
   $Reason = $Results["serv:message"]["serv:header"]["serv:response"]["serv:reason"];
   $RegisterID = $Results["serv:message"]["serv:body"]["serv:bodyContent"]['att:register']["att:registerID"];
 
  if ($Success == 'SUCCESS')
   $Successful = 1;
  else
   $Successful = 0;
   
  $answer = array('success' => $Successful, 'attendeeID' => $AttID, 'reason' =>  $Reason, 'RegisterID' => $RegisterID) ;
  return  $answer;
 }
 

i placed the php files on my php server and edited them to reflect my creds for my GDP account,  but i have blank pages when i try to browse to them,  what step am i missing?

Create a Cisco account today and gain access across all Cisco Collaboration Developer sites.

 

Follow the WebEx Developer program on Twitter for the latest industry and WebEx Meetings related information.