ciao ragazzi, sto studiando come realizzare web robots e spider da un autorevole libro ma mi sono fermato a questo codice che non riesco a far funzionare nonostante sia preso pari pari dal libro. Il codice in esame dovrebbe spedire tramite GET due valori emulando un form.
Codice PHP:
<?php
include("LIB_http.php");

$action "http://www.schrenk.com/search.php";
$method "GET";
$ref "";
$data_array['term'] = "hello";
$data_array['sort'] = "up";
$response http($target=$action$ref$method$data_arrayEXCL_HEAD);
?>
la funzione http del file LIB_http.php è questa:
Codice PHP:
function http($target$ref$method$data_array$incl_head)
    {
    
# Initialize PHP/CURL handle
    
$ch curl_init();

    
# Prcess data, if presented
    
if(is_array($data_array))
        {
        
# Convert data array into a query string (ie animal=dog&sport=baseball)
        
foreach ($data_array as $key => $value
            {
            if(
strlen(trim($value))>0)
                
$temp_string[] = $key "=" urlencode($value);
            else
                
$temp_string[] = $key;
            }
        
$query_string join('&'$temp_string);
        }
        
    
# HEAD method configuration
    
if($method == HEAD)
        {
        
curl_setopt($chCURLOPT_HEADERTRUE);                // No http head
        
curl_setopt($chCURLOPT_NOBODYTRUE);                // Return body
        
}
    else
        {
        
# GET method configuration
        
if($method == GET)
            {
            if(isset(
$query_string))
                
$target $target "?" $query_string;
            
curl_setopt ($chCURLOPT_HTTPGETTRUE); 
            
curl_setopt ($chCURLOPT_POSTFALSE); 
            }
        
# POST method configuration
        
if($method == POST)
            {
            if(isset(
$query_string))
                
curl_setopt ($chCURLOPT_POSTFIELDS$query_string);
            
curl_setopt ($chCURLOPT_POSTTRUE); 
            
curl_setopt ($chCURLOPT_HTTPGETFALSE); 
            }
        
curl_setopt($chCURLOPT_HEADER$incl_head);   // Include head as needed
        
curl_setopt($chCURLOPT_NOBODYFALSE);        // Return body
        
}
        
    
curl_setopt($chCURLOPT_COOKIEJARCOOKIE_FILE);   // Cookie management.
    
curl_setopt($chCURLOPT_COOKIEFILECOOKIE_FILE);
    
curl_setopt($chCURLOPT_TIMEOUTCURL_TIMEOUT);    // Timeout
    
curl_setopt($chCURLOPT_USERAGENTWEBBOT_NAME);   // Webbot name
    
curl_setopt($chCURLOPT_URL$target);             // Target site
    
curl_setopt($chCURLOPT_REFERER$ref);            // Referer value
    
curl_setopt($chCURLOPT_VERBOSEFALSE);           // Minimize logs
    
curl_setopt($chCURLOPT_SSL_VERIFYPEERFALSE);    // No certificate
    
curl_setopt($chCURLOPT_FOLLOWLOCATIONTRUE);     // Follow redirects
    
curl_setopt($chCURLOPT_MAXREDIRS4);             // Limit redirections to four
    
curl_setopt($chCURLOPT_RETURNTRANSFERTRUE);     // Return in string
    
    # Create return array
    
$return_array['FILE']   = curl_exec($ch); 
    
$return_array['STATUS'] = curl_getinfo($ch);
    
$return_array['ERROR']  = curl_error($ch);
    
    
# Close PHP/CURL handle
      
curl_close($ch);
    
    
# Return results
      
return $return_array;
    } 
premetto che ho già attivato l'estensione curl.
ho provato anche a sostituire
Codice PHP:
$response http($target=$action$ref$method$data_arrayEXCL_HEAD); 
con
Codice PHP:
http($target=$action$ref$method$data_arrayEXCL_HEAD); 
ma niente.......pagina bianca.

avete qualche idea?