Hello there
I made a slightly different implementation like on the linked github page, which does 3 web requests with curl.
Example which i used to make a similiary implementation:
The cache mode is set to “cache”, yet the site has really long loading time. I dont think, there is anything cached with in the Neos Frontend Cache, or the EEL Helper Cache.
I played with the settings, but found no solution, that worked.
For example, i added the CacheAwareInterface to the EEL Helper.
So my Question is: How can i cache the EEL Helper Output with the Neos Frontend Cache, or how to use some Caching at PHP level that works?
My tries:
prototype(vendor.instagram:InstagramGallery) < prototype(Neos.Neos:Content) {
templatePath = ‘resource://vendor.instagram/Private/Templates/Instagram.html’
@context.accessTokens = ${q(node).property('accessTokens')}
@context.countImagesPerAccount = ${q(node).property('countImagesPerAccount')}
@context.randomizeImages = ${q(node).property('randomizeImages')}
instagramCollection = ${Instagram.getInstagramFeed('users/self/media/recent', '&count=' + countImagesPerAccount, accessTokens, randomizeImages)}
test = ${Date.now().timestamp}
@cache {
mode = 'cached'
maximumLifetime = '3600'
}
}
PHP:
class Instagram implements ProtectedContextAwareInterface, CacheAwareInterface {
private $accessTokenString;
private $randomizeImages;
public function getInstagramFeed($requestType, $get_param, $accessTokensString, $randomizeImages) {
$this->accessTokenString = $accessTokensString;
$this->randomizeImages = $randomizeImages;
$accessTokensArray = explode("\n", $accessTokensString);
$instagramData = [];
foreach($accessTokensArray as $accessToken) {
$response = $this->getRecentImages($requestType, $get_param, $accessToken);
$decoded_response = json_decode($response);
$newData = isset($decoded_response->data) ? $decoded_response->data : [];
$instagramData = array_merge($instagramData, $newData);
if($randomizeImages) {
shuffle($instagramData);
}
}
return isset($instagramData) ? $instagramData : [];
}
function getRecentImages($requestType, $get_params, $access_token){
$url = "https://api.instagram.com/v1/$requestType/?access_token=$access_token&$get_params";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
public function allowsCallOfMethod($methodName) {
return true;
}
public function getCacheEntryIdentifier() {
return $this->accessTokenString + $this->randomizeImages.toString();
}
}
Regards, Peter