![]() |
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'); |
I posted something similar a while ago - I will see if I can find it...
|
This was my solution:
Code:
<?php |
Quote:
I was using Iframe's showing the top room, but I am targeting heteros, And those Voyeur_Boys are getting popular. |
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:
|
Why not save it to MySQL? Use cron job every 15 minutes.
|
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'; |
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)) { |
Quote:
|
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:Oh crap!.. |
Quote:
|
All times are GMT -7. The time now is 11:29 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123