Jump to content

Simplexml Problem


selenin

Recommended Posts

Hi I want to check if an user is online, if the user is online the object is set otherwise it doesn't exist. I tried it like that but it doesn't work at all.

 

$cams = new SimpleXMLElement('http://chaturbate.com/affiliates/api/onlinerooms/?format=xml&wm=N6TZA', null, true);
if (isset($cams->username['chantal'])){
echo "online";
}

Link to comment
https://forums.phpfreaks.com/topic/269595-simplexml-problem/
Share on other sites

Don't understand this xpath that's what I wrote

 

$cams = new SimpleXMLElement('http://chaturbate.com/affiliates/api/onlinerooms/?format=xml&wm=N6TZA', null, true);
foreach ($cams->xpath('chantal') as $username) {
if ($username == ""){
 echo "not online";
}else{
echo "online";
}
}

Link to comment
https://forums.phpfreaks.com/topic/269595-simplexml-problem/#findComment-1385860
Share on other sites

<?php
$cams = new SimpleXMLElement('http://chaturbate.com/affiliates/api/onlinerooms/?format=xml&wm=N6TZA', null, true);
$online = false;
foreach ($cams->xpath('//username') as $username) {
if ($username == "chantal"){
 echo " $username online<br />";
 $online = true;
}
}
if (!$online) echo "Not online";
?>

Link to comment
https://forums.phpfreaks.com/topic/269595-simplexml-problem/#findComment-1385873
Share on other sites

During development you obviously work on a cached version..

 

$xml = new SimpleXMLElement('chat_cache.xml', null, true);

 

You can download the XML through your browser or using cURL:

 

curl http://chaturbate.com/affiliates/api/onlinerooms/?format=xml&wm=N6TZA > chat_cache.xml

Link to comment
https://forums.phpfreaks.com/topic/269595-simplexml-problem/#findComment-1385926
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.