cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1677
Views
3
Helpful
3
Replies

Test XML API

adolfo00111
Level 1
Level 1

Hi

I'm trying to test XML api with the following php code, (basically the example php code):

///////////////////////////////////////////////////////////////////////////

#

#   LstSummaryMeeting.php

#

#   This example page uses PHP to HTTP POST a WebEx XML request function 

#   which queries for the calling user's meetings.  The WebEx XML Service then

#   returns an XML response document listing each meeting.

#

#   This page should be installed onto a webserver running PHP.

#

#   Author: Phillip Liu, phillipl@webex.com                                            

#   Date:   11/11/04

#

#   (c) Copyright 2004 WebEx Communications

#

///////////////////////////////////////////////////////////////////////////

These variables need to be set...

SID set to your siteid number

UID set to your WebEx username 

PWD set to your WebEx password

PID set to the site partnerID, if you don't know, you can get it from WebEx.

XML_SITE set to a WebEx Site name

-->

<html>

<head>

<title>List WebEx meetings via XML API</title>

</head>

<body>

<?php

    // Specify WebEx site and port

    $XML_SITE="apidemoeu.webex.com";

    $XML_PORT="443";

    // Set calling user information

    $d["UID"] = "Username"; // WebEx username

    $d["PWD"] = "pass"; // WebEx password

    $d["SID"] = "690319"; //Demo Site SiteID

    $d["PID"] = "g0webx!"; //Demo Site PartnerID

    // Build XML request document

    $d["XML"]="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";

    $d["XML"].="<serv:message xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">";

    $d["XML"].="<header>";

    $d["XML"].="<securityContext>";

    $d["XML"].="<webExID>{$d["UID"]}</webExID>";

    $d["XML"].="<password>{$d["PWD"]}</password>";

    $d["XML"].="<siteID>{$d["SID"]}</siteID>";

    $d["XML"].="<partnerID>{$d["PID"]}</partnerID>";

    $d["XML"].="</securityContext>"; 

    $d["XML"].="</header>";

    $d["XML"].="<body>";

    $d["XML"].="<bodyContent xsi:type=\"java:com.webex.service.binding.meeting.CreateMeeting\">";

    $d["XML"].="</bodyContent>";

    $d["XML"].="</body>";

    $d["XML"].="</serv:message>";

    $URL = "https://{$XML_SITE}/WBXService/XMLService";

    $Result = postIt($d,$URL,$XML_PORT);

    //  Output calling user variables

    echo "<b>Calling user variables</b></br>";

    echo "SID={$d["SID"]}<br>";

    echo "UID={$d["UID"]}<br>";

    echo "PID={$d["PID"]}<br>";

    echo "XML_SITE={$XML_SITE}<br>";

    exit;

    //

    //  postIt()

    //

    //  POSTs the XML action document and calling user variables

    //  to the specified WebEx XML Server and receives an XML response document

    //

    function postIt($DataStream, $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, "/");

        //  Form the request body

        $reqBody = "";

        while (list($key, $val) = each($DataStream)) {

            if ($reqBody) $reqBody.= "&";

            $reqBody.= $key."=".urlencode($val);

        }

        $ContentLength = strlen($reqBody);

  $xml = $DataStream['XML'];

        //  Generate the request header

      global $Debug_Mode;

      $Debug_Mode = 1;

      $URL = $Host;

      $fp = fsockopen($URL, $Port,$errno,$errstr);

      $Post =  "POST /WBXService/XMLService HTTP/1.0\n";

      $Post .= "Host: $URL\n";

      $Post .= "Content-Type: application/xml\n"; 

      $Post .= "Content-Length: ".strlen($xml)."\n\n";

      $Post .= "$xml\n";

      if($Debug_Mode){

     echo "<hr>XML Sent:<br><textarea cols=\"50\" rows=\"25\">".htmlspecialchars($xml)."</textarea><hr>";

      }

      if($fp){

     fwrite($fp,$Post);

     $response = "";

     while (!feof($fp)) {

   $response .= fgets($fp, 1024);

     }

     if($Debug_Mode){

   echo "<br>XML Received:<br><textarea cols=\"50\" rows=\"25\">".htmlspecialchars($response)."</textarea><hr>";

     }

   echo "<br>XML Received:<br><textarea cols=\"50\" rows=\"25\">".htmlspecialchars($response)."</textarea><hr>";

     return $response;

      }

      else{

     echo "$errstr ($errno)<br />\n";

     return false;

      }

    }

?>

But no xml response... What was wrong?

Thanks in advance...

3 Replies 3

nmorrow
Cisco Employee
Cisco Employee

Hello,

     You should change the following line

from: $URL = ereg_replace("^http://", "", $URL);

to: $URL = ereg_replace("^https://", "", $URL);

This is because $URL begins with https://, which is not currently being properly stripped due to mismatched string value.

Thank you, Nathan, I will test it.

Adolfo,

Did this change fix your problem?

Appreciate you sharing your code!

DJ

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: