sendRequest($endpoint); if (is_object($data) && $data->success == true){ $obj_content = $data->data; $obj_content = $obj_content->horizontal; $apicaller->cacheData($obj_content, 'getCompanySnippetHorizontal'); echo $obj_content; } } else { // serve from cache if ( is_array($cachedData) && array_key_exists('success', $cachedData) && array_key_exists('data', $cachedData) && $cachedData['success'] == true ) { echo $cachedData['data']; } }} catch (Exception $e) { // try to serve from cache $cachefile = 'cached-richsnippet-horizontal-'.$company_id.'.html'; // check if cache dir exists in root $checkCacheDir = $_SERVER['DOCUMENT_ROOT'].'/cache/'; if ( is_dir($checkCacheDir) ) { $cachefile = $checkCacheDir.$cachefile; }// Serve from the cache if it is younger than $cachetime if ( file_exists($cachefile) ) { echo "\n"; $data = file_get_contents($cachefile); echo $data; } }function checkCache($company_id, $cachetime) { //create cache file with companyId $file = 'richsnippet-horizontal-'.$company_id.'.html'; $cachefile = 'cached-'.$file; // check if cache dir exists in root $checkCacheDir = $_SERVER['DOCUMENT_ROOT'].'/cache/'; if ( is_dir($checkCacheDir) ) { $cachefile = $checkCacheDir.$cachefile; } // Serve from the cache if it is younger than $cachetime if (file_exists($cachefile) && time() - $cachetime < filemtime($cachefile)) {$data = file_get_contents($cachefile); $arr_data = array('success' => true, 'data' => "\n".$data); return $arr_data; } return false; }

Vraag onze studiegids aan!

Bekijk al onze opleidingen in de studiegids.

Voeding & Gewicht

Pagina 1 van 212