Jump to content

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";
?>

Edited by Barand
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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.