Riporto il codice per chi puō aiutarmi
Utente e Password sono fittizie ovviamente.
con quelle vere il risultato a video č il seguente:
codice:
Object Moved
This object may be found here.
Resource id #2
Array ( [url] => http://gpro.net/it/Qualify.asp [content_type] => text/html [http_code] => 302 [header_size] => 295 [request_size] => 298 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.10029 [namelookup_time] => 2.1E-5 [connect_time] => 0.000336 [pretransfer_time] => 0.00034 [size_upload] => 37 [size_download] => 151 [speed_download] => 1505 [speed_upload] => 368 [download_content_length] => 151 [upload_content_length] => 0 [starttransfer_time] => 0.100272 [redirect_time] => 0 [redirect_url] => http://gpro.net/it/Login.asp?Redirect=Qualify.asp )
qualcuno sā come risolvere?
Codice PHP:
<?php
// INIT CURL
$ch = curl_init();
// SET URL FOR THE POST FORM LOGIN
curl_setopt($ch, CURLOPT_URL, 'http://gpro.net/it/Login.asp?Redirect=Qualify.asp');
curl_setopt($ch, CURLOPT_HEADER, 1); // 1 0
# // This is occassionally required to stop CURL from verifying the peer's certificate. for https connections
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 1); //sometimes needs to be 0 or 1...
#
// SET POST PARAMETERS : FORM VALUES FOR EACH FIELD
$user="UTENTE";
$pass="PASSWORD";
$fields = 'textLogin='.urlencode($user).'&textPassword='.urlencode($pass);
// ENABLE HTTP POST
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
curl_setopt($ch, CURLOPT_REFERER, 'https://www.gpro.net/');
// IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
# //the following might be all you need
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // often not set by default, this will recursively follow all redirect headers
#
# // use this option to output all the exchanged info for trying to see what is happening
curl_setopt($ch, CURLOPT_VERBOSE, 1);
# Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL
# not to print out the results of its query.
# Instead, it will return the results as a string return value
# from curl_exec() instead of the usual true/false.
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
//redirect stderr to file stream
$fp = fopen("temp.txt","w");
curl_setopt ($ch, CURLOPT_STDERR, $fp);
//don't forget fclose at the end...
curl_setopt($ch, CURLOPT_REFERER, 'http://gpro.net/it/Qualify.asp');
// EXECUTE 1st REQUEST (FORM LOGIN)
$store = curl_exec ($ch);
// SET FILE TO DOWNLOAD
curl_setopt($ch, CURLOPT_URL, 'http://gpro.net/it/Qualify.asp');
// EXECUTE 2nd REQUEST (FILE DOWNLOAD)
$content = curl_exec ($ch);
echo $content;
echo "
";
echo $ch;
echo "
";
print_r(curl_getinfo($ch));
// CLOSE CURL
curl_close ($ch);
fclose($fp);
?>