| 
		
			
			
				
			
			
				 
			
			
				
			
		 | 
		
			
			
				 
			
				
			
		 | 
	||||
| 
				Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.  You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us.  | 
		
		 
		![]()  | 
	
		
			
  | 	
	
	
		
		|||||||
| Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. | 
| 
		 | 
	Thread Tools | 
| 
			
			 | 
		#1 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Industry Role:  
				Join Date: Jul 2012 
				
				
				
					Posts: 3,089
				 
				
				
				
				 | 
	
	
	
	
		
			
			 
				
				Caching an XML file - Does this PHP cod look okay?
			 
			I want to use Chaturbate's XML feed,  But I want to save the XML file off periodically and use that instead of hitting Chaturbate's XML file every time.  This code seems to work,  But do you see any problems or ways to improve? 
		
	
		
		
		
		
			Code: 
	$feed_updated = filemtime('mysaved.xml');
$current_time = time();
if($current_time - $feed_updated >= 300) {
        $xml_feed_url = 'https://chaturbate.com/affiliates/api/onlinerooms/?format=xml&wm=0CLZb';
        $savefile = "yes";
} else {
        $xml_feed_url = 'http://www.bestfreecamgirls.com/mysaved.xml';
        $savefile = "no";
        echo " testing - using saved";
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $xml_feed_url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_TIMEOUT,5);
$xml = curl_exec($ch);
if ($savefile == "yes"){
    file_put_contents('mysaved.xml', $xml);}
curl_close($ch);
				__________________ 
		
		
		
		
	
	Live Sex Shows  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#2 | 
| 
			
			
			
			 Just Doing My Own Thing 
			
		
			
				
			
			
			Industry Role:  
				Join Date: Jan 2011 
				Location: London, Spain, New Zealand, GFY - Not Croydon... 
				
				
					Posts: 25,248
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 I posted something similar a while ago - I will see if I can find it... 
		
	
		
		
		
		
		
	
	 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#3 | 
| 
			
			
			
			 Just Doing My Own Thing 
			
		
			
				
			
			
			Industry Role:  
				Join Date: Jan 2011 
				Location: London, Spain, New Zealand, GFY - Not Croydon... 
				
				
					Posts: 25,248
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 This was my solution: 
		
	
		
		
		
		
		
	
	Code: 
	<?php 
$cacheName = 'chatcache.xml'; 
$ageInSeconds = 60; 
  
if(!file_exists($cacheName) || filemtime($cacheName) > time() + $ageInSeconds);  
{ 
  $contents = file_get_contents('http://chaturbate.com/affiliates/api/onlinerooms/?format=xml&wm=isCir'); 
  file_put_contents($cacheName, $contents); 
} 
?>
 | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#4 | |
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Industry Role:  
				Join Date: Jul 2012 
				
				
				
					Posts: 3,089
				 
				
				
				
				 | 
	
	
	
	
		
			
			 Quote: 
	
 I was using Iframe's showing the top room, but I am targeting heteros, And those Voyeur_Boys are getting popular. 
				__________________ 
		
		
		
		
	
	Live Sex Shows  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#5 | ||
| 
			
			
			
			 see you later, I'm gone 
			
		
			
			
			Industry Role:  
				Join Date: Oct 2002 
				
				
				
					Posts: 14,127
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
 Why do the page pull (curl) each time? You have the feed saved as mysaved.xml every 5 minutes. Just use that file as the feed in the program and don't do the curl every time. Quote: 
	
 
				__________________ 
		
		
		
		
	
	All cookies cleared!  | 
||
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#6 | 
| 
			
			
			
			 Confirmed User 
			
		
			
				
			
			
			Industry Role:  
				Join Date: Oct 2003 
				Location: L.A. 
				
				
					Posts: 5,744
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Why not save it to MySQL? Use cron job every 15 minutes. 
		
	
		
		
		
		
			
				__________________ 
		
		
		
		
	
	  Blog Posts - Contextual Links - Hardlinks on 600+ Blog Network  * Handwritten * 180 C Class IPs * Permanent! * Many Niches! * Bulk Discounts! GFYPosts /at/ J2Media.net  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#7 | |
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Industry Role:  
				Join Date: Jul 2012 
				
				
				
					Posts: 3,089
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
 Here is my code now. Calling Curl on my own server is stupid, But I am getting a problem in the SimpleXMLElement function if I don't. My problem is a lack of understanding of XML. I am sure it is something simple, I just need to figure out. Code: 
	$cacheName = 'chatcache.xml'; 
$feed_updated = filemtime('chatcache.xml');
$ageInSeconds = 120; 
  
if(!file_exists($cacheName) || time() > $feed_updated + $ageInSeconds)
{ 
  echo "file saved";
  $contents = file_get_contents('https://chaturbate.com/affiliates/api/onlinerooms/?format=xml&wm=0CLZb'); 
  file_put_contents($cacheName, $contents); 
} 
$xml_feed_url = 'http://www.bestfreecamgirls.com/chatcache.xml';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $xml_feed_url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch,CURLOPT_TIMEOUT,5);
$xml = curl_exec($ch);
curl_close($ch);
$resource =  $chat->resource;
$gender = $chat->resource->gender;
$female = "f";
$counter = 0;
if ($xml != NULL){
$chat = new SimpleXMLElement($xml);
}
				__________________ 
		
		
		
		
	
	Live Sex Shows  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#8 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Industry Role:  
				Join Date: Jul 2012 
				
				
				
					Posts: 3,089
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Thanks all.   
		
	
		
		
		
		
			Nevermind. Got it. Curl completely pulled. Had to load the file into xml this way instead of simplexmlelement used simplexml_load_file. Although, I may switch to using curl for the copy instead of file_put_contents, So I can set a timeout if there is an issue with Chaturbate's XML file. Code: 
	if (file_exists($cacheName)) {
    $chat = simplexml_load_file($cacheName);
} else {
    exit('Failed to open test.xml.');
}
				__________________ 
		
		
		
		
	
	Live Sex Shows  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#9 | 
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Industry Role:  
				Join Date: Jul 2012 
				
				
				
					Posts: 3,089
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 I like that idea too.  That way the user doesn't have to wait if the file needs to be updated. 
		
	
		
		
		
		
			
				__________________ 
		
		
		
		
	
	Live Sex Shows  | 
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#10 | |
| 
			
			
			
			 Just Doing My Own Thing 
			
		
			
				
			
			
			Industry Role:  
				Join Date: Jan 2011 
				Location: London, Spain, New Zealand, GFY - Not Croydon... 
				
				
					Posts: 25,248
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
 However..... You have got me back into this project and I am looking at using a DB so you can build up the database with all the cammers in it - Then mark them as on or off line using the XML file - That way you can build your own 'Cam Offline' and profile pages with the data... As you collect more data you can create more complex pages with lots of info for the SEs..... NEED MORE COFFEE  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
| 
			
			 | 
		#11 | |
| 
			
			
			
			 Confirmed User 
			
		
			
			
			Industry Role:  
				Join Date: May 2011 
				Location: San Diego 
				
				
					Posts: 328
				 
				
				
				
				 | 
	
	
	
	
		
		
		
		 Quote: 
	
  | 
|
| 
		 | 
	
	
	
		
                 
		
		
		
		
		
		
		
			
			
		
	 | 
			 
			 
		 | 
		
	|||||||
		
			
  | 
	|||||||
| Bookmarks |