login."@".$this->password."@".$timestamp); $preToken = $this->login."@".$timestamp."@".$hash; $urlGetToken = $ACCESSOR_URL . 'token/generate.aspx?auth=' . urlencode($preToken) . '&ip=' . urlencode($_SERVER["REMOTE_ADDR"]); $fh = @fopen($urlGetToken, 'rb'); if ($fh == false) return false; $token = ''; while (!feof($fh))$token .= fread($fh, 8192); fclose($fh); return ($token); } protected function cleanAdress($ville) { $ville = ' '.trim(preg_replace('/([0-9]|ARRONDISSEMENT|_)/i', ' ', $ville)).' '; $ville = trim(strtr($ville, array(' EME ' => '', ' ER ' => ''))); return (ucwords(strtolower($ville))); } public function villeCouverte($ville) { $ville = $this->cleanAdress($ville); if (in_array(strtoupper($ville),$this->villes)){ return true; } return false; } public function getJs() { $token = $this->getToken(); $href = 'http://axe.mappy.com/1v1/init/get.aspx?auth='.$token.'&version=2.01&solution=ajax'; return $href; } }