-1

I have used webex data to display the meeting in my website however I am getting an issue with returning the data.

$sitename = "sitename";       
$username = "api@webex.com";
$password = "password!";

$XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
$XML .="<serv:message xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">";
$XML .="        <header>";
$XML .="                <securityContext>";
$XML .="                        <webExID>$username</webExID>";
$XML .="                        <password>$password</password>";
$XML .="                        <siteName>$sitename</siteName>";

$XML .="                </securityContext>";
$XML .="        </header>";
$XML .="        <body>";
$XML .="                <bodyContent xsi:type=\"java:com.webex.service.binding.meeting.GetjoinurlMeeting\">";
$XML .="                <meetingKey>1460755337</meetingKey>";
$XML .="                </bodyContent>";
$XML .="        </body>";
$XML .="</serv:message>";

$request = stream_context_create(array("http"=>array("method"=>"POST","header"=>"Content-Type:text/xml","content"=>$XML)));

$response = file_get_contents("https://$sitename.webex.com/WBXService/XMLService", true, $request);

Actual XML response enter image description here and I am getting a response as follow after passing header request

SUCCESSPRIMARYfalsefalseC!sco123falsefalseMeeting 13 jjb87@miami.edufalse1myemail@gmail.commyemail@gmail.comPERSONALmyemail@gmail.comVISITOR1097099526INVITE1467275084ENGLISHATTENDEE1truetruetruetruetruetruetruetruetruetruefalsefalsefalsefalsefalsefalsefalsefalsefalsefalsetruetruetruefalsefalsetruefalsetruefalsefalsetruetruefalsefalsefalsetruefalsefalsetruefalsefalsefalsefalsefalsefalsefalsetruefalsefalsefalsetruefalsefalsefalsetruetruetrue07/10/2020 12:00:004GMT-08:00, Pacific (San Jose)20900rachel@modiht.comfalsefalse000falsefalsefalseCALLBACK50falsefalseUS+1-415-655-00011-844-621-3956falsefalseNO_REPEATtruerachel@modiht.comtruefalse0015falsefalsefalse0falsefalse146727508475c9ca6757090f047a57136a85ee09cbNOT_INPROGRESSfalsefalsefalse50223710221954770ec6374b4ace66655ed33b7bcf0a9ac61019001truehttps://api.webex.com/modiht/j.php?MTID=m32de914bf4153f200c60e1ad420376ed1467275084@api.webex.com1467275084@api.webex.com

so My question is how can I get the last one 1467275084@api.webex.com from the response

please help me out on this.

Kunal Raut
  • 2,495
  • 2
  • 9
  • 25
Tejas Gajjar
  • 250
  • 1
  • 11
  • 2
    Have a look at the actual content of `$response` (easiest way is to view the source of the output page), you will probably find there are XML tags in there which the browser is taking as HTML tags. – Nigel Ren Jul 14 '20 at 14:08
  • 1
    PHP has various tools you can use to get the data you want from the XML response. Check out https://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php. – Don't Panic Jul 14 '20 at 14:10
  • can you show me the example of how can I do it? @NigelRen – Tejas Gajjar Jul 14 '20 at 14:10
  • There are general examples in the post I linked, but I don't think anyone will be able to tell you how to get the exact piece of data you want form the response without seeing the response XML. – Don't Panic Jul 14 '20 at 14:13
  • I have edited my question with XML response – Tejas Gajjar Jul 14 '20 at 14:17
  • You couldn't have pasted the actual xml text as part of your question? Images suck. – IncredibleHat Jul 14 '20 at 14:46

2 Answers2

0

Ok I did it with the preg match here is the answer to my question

$emails = getLastEmailFromString($response);
$arrEmail = implode("\n", $emails);
$lastEMail = end( $emails);
return $lastEMail;

function getLastEmailFromString($string){
  preg_match_all("/[\._a-zA-Z0-9-]+@[\.api.webex.com-]+/i", $string, $matches);
  return $matches[0];
}
Tejas Gajjar
  • 250
  • 1
  • 11
-1

the file() method returns the results as an array, which may be more suited for your needs here.

$response = file("https://$sitename.webex.com/WBXService/XMLService", true, $request);
$lastLine = $response[count($response)-1];

https://www.php.net/manual/en/function.file.php

James Clark
  • 1,285
  • 2
  • 9
  • 14