我正在嘗試使用Curl登錄到https://www.reporo.com/login.php。下面是代碼,我使用的是:它重定向我http://best-payroll-services.info/adder/login.phpCurl https登錄
<?php
function createPostString($aPostFields) {
foreach ($aPostFields as $key => $value) {
$aPostFields[$key] = urlencode($key . '=' . $value);
}
return urlencode(implode('&', $aPostFields));
}
$postFields['username'] = 'login';
$postFields['password'] = 'pass';
$postFields['submit'] = ' ';
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'https://www.reporo.com/login.php');
curl_setopt($curl, CURLOPT_REFERER, 'https://www.reporo.com/login.php');
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13');
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/cookies.txt');
curl_setopt($curl, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookies.txt');
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, createPostString($postFields));
curl_exec($curl);
header('Location: https://www.reporo.com/analytics/dashboard.php');
curl_close($curl)
?>
使用腳本之後。哪裏有問題 ?
的var_dump(curl_getinfo($ C))之後,我已經有了:
'url' => string 'https://www.reporo.com/login.php' (length=32)
'content_type' => string 'text/html' (length=9)
'http_code' => int 200
'header_size' => int 382
'request_size' => int 192
'filetime' => int -1
'ssl_verify_result' => int 20
'redirect_count' => int 0
'total_time' => float 0.843
'namelookup_time' => float 0
'connect_time' => float 0.109
'pretransfer_time' => float 0.531
'size_upload' => float 255
'size_download' => float 3233
'speed_download' => float 3835
'speed_upload' => float 302
'download_content_length' => float 3233
'upload_content_length' => float 255
'starttransfer_time' => float 0.655
'redirect_time' => float 0
'certinfo' =>
array
empty
'redirect_url' => string '' (length=0)
問候。
請問你到底用什麼代碼實現?如果登錄是正確的,您還希望重定向到哪裏? – tftd
我試圖登錄到reporo.com,但它不起作用;/ –
所以,如果我理解你是正確的,你有一個腳本(運行在不同的服務器上),應該檢查你是否有cookies。如果不是,腳本會將登錄後數據發送到遠程腳本(位於@ reporo.com),然後重定向。那是對的嗎? – tftd