View Single Post
Old 11-04-2022, 09:45 AM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,059
Emma,

You asked about what you would do with the code from this thread

https://gfy.com/fucking-around-and-b...-api-help.html

Quote:
$flname="/server file path/filename";
$url="xml url";
$data=file_get_contents($url);
if(!empty($data))
{
file_put_contents($flname,$data);
}
else
{
echo "Did not get a file back<br>\n";
}
That is pseudo code for a caching system for the stand alone version of the nmip chaturbate script.

The WP plugin handles the xml feed differently than that. I took a look at the code in the import.php file from the wp plugin. I am not sure how you could speed that up. The caching scheme I wrote about will not work with the WP plugin without a fair amount of modification of the plugin code. I also don't think you would get any speed improvements from it. According to the setup.txt file in the plugin the import already runs imtermittently so it is not being called on every hit.

With that said. If you are using the stand alone script then the code above goes into a separate program that is called periodoically as a cron job on the server. Then you replace the existing call to the chaturbate api with a call to the local file created by the cron.

A simple version of the cron job would be something like:
<?php

if(data=file_get_contents($chatfeedlink='https://chaturbate.com/affiliates/api/onlinerooms/?format=xml&wm=XXXXX'))
{
file_put_contents('home/website/cache/xmlcache.xml',$data);
}
else
{
// do some sort of error routine here
}

?>

You would replace the path and file name in the file_put_contents() call with the
applicable path and file name for your server.

You would set the cron to pull that periodoically. 5 minutes is what I was using originally and it worked pretty good.

In the stand alone version of the nmip script you would change the call to the xml feed with the call to the local file.

On lines 82 and 330 of the functions.php file you would change the code for the xml pull.

the existing line: $xml = 'http://' . CBWL . '/affiliates/api/onlinerooms/?format=xml&wm='.$affid.'';

would be changed to pull from the file you created with your cron:

$xml='home/website/cache/xmlcache.xml';

That is the simplest version of it that I can come up with.

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