Pogledajte određenu poruku
Staro 18. 07. 2011.   #1
webarto
expert
Grand Master
 
Avatar webarto
 
Datum učlanjenja: 11.04.2010
Poruke: 998
Hvala: 141
890 "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 PHP Alexa Class

PHP kôd:
class Alexa{

    
/**
     * @author Webarto
     * @copyright 2011
     */
    
    /** Load and parse data, return rank */
    
function check($url){
        
        
$xml $this->curl("http://data.alexa.com/data?cli=10&dat=s&url=$url"); // Fetch data
        
$rank $this->match('TEXT="([0-9]+)"'$xml); // Parse rank from XML file
        
return $rank// Return numeric rank
    
    
}
    
    
/** cURL helper function for data fetching */
    
private function curl($url){
        
        
$curl curl_init();
        
curl_setopt($curlCURLOPT_URL$url);
        
curl_setopt($curlCURLOPT_ENCODING"gzip");
        
curl_setopt($curlCURLOPT_RETURNTRANSFER1);
        
$data curl_exec($curl);
        
curl_close($curl);
        return 
$data;
    
    }
        
    
/** RegEx match helper function */
    
private function match($regex$string){
        
preg_match("#$regex#is"$string$matches);
        return 
$matches[1];
    }


Juzidž...

PHP kôd:
$alexa = new Alexa// Make new instance
$url "http://webarto.com"// Set URL
echo $alexa->check($url); // Print result (884181) 
__________________
Github // LinkedIn // PHP // ZCE // Stackoverflow PHP // Site5 Web Hosting
webarto je offline   Odgovorite uz citat