Pogledajte određenu poruku
Staro 12. 09. 2010.   #1
webarto
expert
Grand Master
 
Avatar webarto
 
Datum učlanjenja: 11.04.2010
Poruke: 998
Hvala: 141
959 "Hvala" u 153 poruka
webarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished roadwebarto is on a distinguished road
Default ViaMichelin PHP Class

PHP kôd:
class VM{
/**
 * ViaMichelin.com City2Hash PHP Class
 * @author Webarto.com
 * @copyright 2010
 * @website http://webarto.com/53/viamichelin-php-class
 */
    
    
public function generateLink($from$to){
    return 
'<a href="http://www.viamichelin.com/web/Itineraires?strStartLocid='.$this->getHash($from).'&amp;strDestLocid='.$this->getHash($to).'">Click here to get route from '.ucwords($from).' to '.ucwords($to).'</a>';   
    }
    
    private function 
getHash($city){
        
$city urlencode($city);
        
//cURL 4-5x faster than file_get_contents()
        
$ch curl_init();
        
curl_setopt($chCURLOPT_URL"http://www.viamichelin.com/vmw2/maf/dyn/controller/jseLocationFinder?strMerged=$city");
        
curl_setopt($chCURLOPT_RETURNTRANSFER1);
        
$data curl_exec($ch);
        
curl_close ($ch);
        
//Return hash from data
        
preg_match('/gf : \"(.*?)\"/'$data$bingo);
        if(!empty(
$bingo[1])) return $bingo[1];
    }

Pozivanjem funkcije...

PHP kôd:
$vm = new VM;
echo 
$vm->generateLink("beograd""novi sad"); //from city, to city 
Dobijemo...

<a href="http://www.viamichelin.com/web/Itineraires?strStartLocid=31NDIxOTMxMGNORFF1T0RBMU 56ST1jTWpBdU5EZzBNRFk9&strDestLocid=31NDIxZG0xMGNO RFV1TWpRM01qST1jTVRrdU9ESXlPRFE9">Click here to get route from Beograd to Novi Sad</a>

Odnosno KLIK

Odnosno

Nadam se da će pomoći nekome.

Homepage: http://webarto.com/53/viamichelin-php-class

Poslednja izmena od bluesman : 19. 09. 2010. u 22:10.
webarto je offline   Odgovorite uz citat
7 članova zahvaljuje webarto za poruku: