Closed aethatsme closed 5 years ago
You can build a tiny proxy and cache your responses from the Facebook Graph API. This way you will only have non cached requests going out to Facebook to fetch new data. Cache on the proxy can be set to 24h so you always get fresh data with maximum one day of delay, but I guess you do not upload your photos often than that.
would something like this work?
function get_data($url) { /* @var $cache_file is path/to/the/cache/file/based/on/md5/url / $cache_file = 'cache' . DIRECTORY_SEPARATOR . md5($url); if(file_exists($cache_file)){ /**
Using the last modification date of the cache file to check its validity */ if(filectime($cache_file) < strtotime('-60 minutes')){ unlink($cache_file); } else { echo 'TRACE -- REMOVE ME -- out of cache'; /**
$ch = curl_init(); $timeout = 5; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $data = curl_exec($ch); curl_close($ch);
/**
return $data; }
This looks like PHP to me. Not a great expert with it, but I guess this is one way to do it by saving it to the file.
Is there a way to spread out the api request to facebook? Looks like they are only allowing 200 call per user.
Any help would be appreciated.