View Single Post
Old 12-20-2015, 08:34 AM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,053
The load and parse of the xml feed in there is:

Code:
$userlist = simplexml_load_file('https://chaturbate.com/affiliates/api/onlinerooms/?
format=xml&wm=XXXXX');

if(empty($userlist))
{
  die('Danger Will Robinson...xml load failed...aborting');
}

foreach ($userlist as $user) 
{
  Do something here
}
This opens the xml feed and loads it into a soimplexml object:
$userlist = simplexml_load_file('https://chaturbate.com/affiliates/api/onlinerooms/?format=xml&wm=JkjyU');

If we don't get anything back then lets just kill the routine
if(empty($userlist))
{
die('Danger Will Robinson...xml load failed...aborting');
}

Otherwise we read through the list of nodes returned and do something with the information:

foreach ($userlist as $user)
{
Do something here
}


So, that is a basic parse. There are other ways to pull this off. I usually use a curl routine to grab the xml feed. I do that because with curl I can control the connection timeout and process timeout. You could also use a file_get_contents to open the file and then load it to a simplexml object.

The main thing is that you want to get the data from the xml feed into the simplexml object to make it easier to read by just being able to loop through it.

.
__________________
All cookies cleared!
sarettah is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote