public function getImage($id) { $json = getCached('getImage.wp.' . $id, function () use($id) { return file_get_contents("https://fr.wikipedia.org/w/api.php?action=query&pageids={$id}&prop=pageimages&format=json"); }); $tab = json_decode($json, true); $seg = array_get($tab, 'query.pages.' . $id . '.thumbnail.source'); return str_replace('50px-', '360px-', $seg); }
public function weather($lat, $lng) { $url = "http://vmrest.viamichelin.com/apir/1/weather.json2?center={$lng}:{$lat}&todayForecast=true&fullForecast=true&nbDays=1&atLeastOne=true&obfuscation=false&ie=UTF-8&charset=UTF-8&authKey=JSBS20110216111214120400892678&lg=fra"; // $json = $this->dwn($url); $json = getCached('geoweather.' . sha1(serialize(func_get_args())), function () use($url) { return dwn($url); }, strtotime('+1 hour')); $tab = json_decode($json, true); if (isset($tab['weatherStationList'])) { if (is_array($tab['weatherStationList'])) { return $tab['weatherStationList'][0]['observation']; } } }