Bu verileri yolluyor tabi _viewstate kısmı nasıl oluşturuluyor onu bulman gerek.
Merhaba.
Cevabınız için teşekkür ederim. Örnek kodlar yardımı ile herhalde girişi sağladım fakat bomboş bir ekran görünüyor. Kullandığım kodlar aşağıdadır. Ben nerede eksik yapıyorum? Teşekkürler.
<?
error_reporting(0);
function get_headers_from_curl_response($headerContent)
{
$headers = array();
// Split the string on every "double" new line.
$arrRequests = explode("\r\n\r\n", $headerContent);
// Loop of response headers. The "count() -1" is to
//avoid an empty row for the extra line break before the body of the response.
for ($index = 0; $index < count($arrRequests) -1; $index++) {
foreach (explode("\r\n", $arrRequests[$index]) as $i => $line)
{
if ($i === 0)
$headers[$index]['http_code'] = $line;
else
{
list ($key, $value) = explode(': ', $line);
$headers[$index][$key] = $value;
}
}
}
return $headers;
}
function regexExtract($text, $regex, $regs, $nthValue)
{
if (preg_match($regex, $text, $regs)) {
$result = $regs[$nthValue];
}
else {
$result = "";
}
return $result;
}
$regexViewstate = '/__VIEWSTATE\" value=\"(.*)\"/i';
$regexEventVal = '/__EVENTVALIDATION\" value=\"(.*)\"/i';
$ch = curl_init("http://mail.burulas.com.tr/Mondo/lang/sys/Login.aspx");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
$response = curl_exec($ch);
curl_close($ch);
$viewstate = regexExtract($response,$regexViewstate,$regs,1);
$eventval = regexExtract($response, $regexEventVal,$regs,1);
$params = array(
'__EVENTTARGET' => '',
'__EVENTARGUMENT' => '',
'__VIEWSTATE' => $viewstate,
'__EVENTVALIDATION' => $eventval,
'txtUsername' => 'login',
'txtPassword' => 'pass',
'dlLanguages' => 'tr',
'ddlSkins' => 'Mondo',
'loginParam' => 'SubmitLogin',
);
$ch2 = curl_init("http://mail.burulas.com.tr/Mondo/lang/sys/Login.aspx");
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch2, CURLOPT_HEADER, 1);
curl_setopt ($ch2, CURLOPT_POST, true);
curl_setopt($ch2, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch2, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt ($ch2, CURLOPT_COOKIE,'cookies.txt');
curl_setopt($ch2,CURLOPT_COOKIEJAR,'cookies2.txt');
$response2 = curl_exec($ch2);
curl_close($ch2);
foreach(get_headers_from_curl_response($response2) as $value)
{
foreach($value as $key => $value2)
{
echo $key . ": " .$value2 . "<br />";
}
}
preg_match_all('@<span id="lUsage">(.*?)</span>@si',$response2,$veri_derece1);
echo $veri_derece1[0][0];
?>İstediğim lUsage kısmını ekrana yansıtmak hepsi o.
Ekranın bana çıkardığı yazı da aşağıdadır.
http_code: HTTP/1.1 100 Continue
http_code: HTTP/1.1 302 Found
Cache-Control: private
Content-Length: 153
Content-Type: text/html; charset=utf-8
Location: /Mondo/lang/sys/default.aspx
Server: Microsoft-IIS/7.5
X-AspNet-Version: 2.0.50727
Set-Cookie: NSC_DMVTUFS13_XFCNBJM=ffffffff5d41a04b45525d5f4f58455e445a4a423660;expires=Mon, 23-Mar-2015 16:19:20 GMT;path=/;httponly
X-Powered-By: ASP.NET
Date: Mon, 23 Mar 2015 15:49:58 GMT
Ekranın çıktısı da bu. Teşekkürler.