Comments (3)
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.
from facebook-album-browser.
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';
/*
* unserializing the object on the cache file
* so it gets is original "shape" : object, array, ...
*/
return unserialize(file_get_contents($cache_file));
}
}
$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);
/**
* We actually did the curl call so we need to (re)create the cache file
* with the string representation of our curl return we got from serialize
*/
file_put_contents($cache_file, serialize($data));
return $data;
}
from facebook-album-browser.
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.
from facebook-album-browser.
Related Issues (20)
- FBAB stopped working HOT 3
- Show photos in an albim HOT 2
- Thumbnails taking to long load or not loading HOT 4
- Plugin stopped working HOT 1
- Stopped working HOT 1
- if number of images in the folder is < photosPageSize
- Album only loading partially.
- Change Language HOT 3
- FBAB Works on local site, but not web host HOT 6
- target_blank HOT 1
- How to open actual size image on click? HOT 2
- Rejection of Extended permission user_photos HOT 1
- Not working HOT 1
- Can't get album to load for account HOT 14
- Linked facebook albums are not loading HOT 1
- Rate Limit Reached HOT 1
- Facebook Album no longer working HOT 1
- Cannot read property 'length' of undefined HOT 1
- Issue Regarding the Facebool Albums. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from facebook-album-browser.