Jump to content

Recommended Posts

hi,

 

i am trying to login an ashx page with curl. Following data from livehttpheaders:

 

http://www.milliyetemlak.com/ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx

POST /ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx HTTP/1.1
Host: www.milliyetemlak.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: tr-tr,tr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-9,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: text/plain; charset=utf-8
X-AjaxPro-Method: Login
Referer: http://www.milliyetemlak.com/Default.aspx?aType=UyeGiris
Content-Length: 204
Cookie: IlanOnPlan=FlashIlan=9; KategoriyeGoreIlanlar=12,13,=12; FirmaOnplan=FirmaVitriniEmlakci=0&FirmaVitrinInsaat=0&FirmaVitrinYapiDekorasyon=0&NakliyeciVitrini=0; __utma=183063866.786731720.1278014512.1278164210.1278174821.6; __utmz=183063866.1278014512.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); FirmaOnplan1=FirmaVitriniEmlakci1=0&FirmaVitrinInsaat1=0&FirmaVitrinYapiDekorasyon1=0&NakliyeciVitrini1=0; ASP.NET_SessionId=kt33i5yukc1pvu55gf5jnojl; NSC_fnmblnjmmjzfu=ffffffffd6fb026745525d5f4f58455e445a4a423660; __utmc=183063866; bttest__=123; LoginInfo=email=&password=; __utmb=183063866.3.10.1278174821
Pragma: no-cache
Cache-Control: no-cache
{"username":"mirzazeyrek@gmail.com","password":"mypassword","rememberMe":true,"userip":"213.243.28.145","useragent":"Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )"}
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 41
Content-Type: text/plain; charset=utf-8
Expires: -1
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Set-Cookie: LoginInfo=email=17CC6ABA347F6FC659FD9DF4BE522553A0C2C1FEAF4021F5DF611A33FB6DAD440F34DD64B16A84DBD2F6AC246FC474DC3DF2B616F6A7BD4CFF429F47ABF7607C69D2E92A577D709D666A115F9739E0EB31D05A7DFFF9ECBCD21202ED28BFB153B0831864878BC8D447F7F390F1653BA9&password=337AAE4F702987DC86AF42DB5E26974E166B019F19819207A07029BF3C3DA46CBF3654DA4C03F4ECC41A26150810A6CF18DAB880624EC8930005F3FC7B56B433313728E095025F6B573396D8D03C72E6; expires=Fri, 01-Oct-2010 16:35:18 GMT; path=/
Set-Cookie: NSC_fnmblnjmmjzfu=ffffffffd6fb026745525d5f4f58455e445a4a423660;expires=Sat, 03-Jul-2010 20:28:20 GMT;path=/;httponly
Date: Sat, 03 Jul 2010 16:35:17 GMT

 

and this is my php code for it:

 

<?php

$loginurl = "http://www.milliyetemlak.com/ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx";

echo curl_login($loginurl,$data,'','off');
echo "<br><hr><br>";
// loginning
echo curl_grab_page('http://www.milliyetemlak.com/','','off');
echo "<br><hr><br>";

// ilan gönderiyoruz

function curl_login($url,$data,$proxy,$proxystatus){
    $fp = fopen("cookie.txt", "w");
    fclose($fp);
    $login = curl_init();
    curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt");
    curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt");
    curl_setopt($login, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
    curl_setopt($login, CURLOPT_TIMEOUT, 40);
    curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
    if ($proxystatus == 'on') {
        curl_setopt($login, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($login, CURLOPT_HTTPPROXYTUNNEL, TRUE);
        curl_setopt($login, CURLOPT_PROXY, $proxy);
    }
    curl_setopt($login, CURLOPT_URL, $url);
    curl_setopt($login, CURLOPT_HEADER, TRUE);
    curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($login, CURLOPT_POST, TRUE);
    curl_setopt($login, CURLOPT_POSTFIELDS, '{"username":"mirzazeyrek@gmail.com","password":"mypassword","rememberMe":true,"userip":"213.243.28.145","useragent":"Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )"}');
    ob_start();      // prevent any output
    return curl_exec ($login); // execute the curl command
    ob_end_clean();  // stop preventing output
    curl_close ($login);
    unset($login);    
}               

function curl_grab_page($site,$proxy,$proxystatus){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    if ($proxystatus == 'on') {
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
        curl_setopt($ch, CURLOPT_PROXY, $proxy);
    }
    curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
    curl_setopt($ch, CURLOPT_URL, $site);
    ob_start();      // prevent any output
    return curl_exec ($ch); // execute the curl command
    ob_end_clean();  // stop preventing output
    curl_close ($ch);
}

?>

 

and following code is here:

 

http://www.sozluklerinefendisi.com/mitest.php

 

it isn't working.

 

created cookie.txt is here:

 

# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

www.milliyetemlak.com	FALSE	/	FALSE	1278188457	NSC_fnmblnjmmjzfu	ffffffffd6fb026745525d5f4f58455e445a4a423660

 

any idea ?

 

thanks for looking anyway : )

Link to comment
https://forums.phpfreaks.com/topic/206644-curl-login-problem-with-ashx-page/
Share on other sites

hi,

 

i am trying to login an ashx page with curl. Following data from livehttpheaders:

 

http://www.milliyetemlak.com/ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx

POST /ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx HTTP/1.1
Host: www.milliyetemlak.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: tr-tr,tr;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-9,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Content-Type: text/plain; charset=utf-8
X-AjaxPro-Method: Login
Referer: http://www.milliyetemlak.com/Default.aspx?aType=UyeGiris
Content-Length: 204
Cookie: IlanOnPlan=FlashIlan=9; KategoriyeGoreIlanlar=12,13,=12; FirmaOnplan=FirmaVitriniEmlakci=0&FirmaVitrinInsaat=0&FirmaVitrinYapiDekorasyon=0&NakliyeciVitrini=0; __utma=183063866.786731720.1278014512.1278164210.1278174821.6; __utmz=183063866.1278014512.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); FirmaOnplan1=FirmaVitriniEmlakci1=0&FirmaVitrinInsaat1=0&FirmaVitrinYapiDekorasyon1=0&NakliyeciVitrini1=0; ASP.NET_SessionId=kt33i5yukc1pvu55gf5jnojl; NSC_fnmblnjmmjzfu=ffffffffd6fb026745525d5f4f58455e445a4a423660; __utmc=183063866; bttest__=123; LoginInfo=email=&password=; __utmb=183063866.3.10.1278174821
Pragma: no-cache
Cache-Control: no-cache
{"username":"mirzazeyrek@gmail.com","password":"mypassword","rememberMe":true,"userip":"213.243.28.145","useragent":"Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )"}
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 41
Content-Type: text/plain; charset=utf-8
Expires: -1
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Set-Cookie: LoginInfo=email=17CC6ABA347F6FC659FD9DF4BE522553A0C2C1FEAF4021F5DF611A33FB6DAD440F34DD64B16A84DBD2F6AC246FC474DC3DF2B616F6A7BD4CFF429F47ABF7607C69D2E92A577D709D666A115F9739E0EB31D05A7DFFF9ECBCD21202ED28BFB153B0831864878BC8D447F7F390F1653BA9&password=337AAE4F702987DC86AF42DB5E26974E166B019F19819207A07029BF3C3DA46CBF3654DA4C03F4ECC41A26150810A6CF18DAB880624EC8930005F3FC7B56B433313728E095025F6B573396D8D03C72E6; expires=Fri, 01-Oct-2010 16:35:18 GMT; path=/
Set-Cookie: NSC_fnmblnjmmjzfu=ffffffffd6fb026745525d5f4f58455e445a4a423660;expires=Sat, 03-Jul-2010 20:28:20 GMT;path=/;httponly
Date: Sat, 03 Jul 2010 16:35:17 GMT

 

and this is my php code for it:

 

<?php

$loginurl = "http://www.milliyetemlak.com/ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx";

echo curl_login($loginurl,$data,'','off');
echo "<br><hr><br>";
// loginning
echo curl_grab_page('http://www.milliyetemlak.com/','','off');
echo "<br><hr><br>";

// ilan gönderiyoruz

function curl_login($url,$data,$proxy,$proxystatus){
    $fp = fopen("cookie.txt", "w");
    fclose($fp);
    $login = curl_init();
    curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt");
    curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt");
    curl_setopt($login, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
    curl_setopt($login, CURLOPT_TIMEOUT, 40);
    curl_setopt($login, CURLOPT_RETURNTRANSFER, TRUE);
    if ($proxystatus == 'on') {
        curl_setopt($login, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($login, CURLOPT_HTTPPROXYTUNNEL, TRUE);
        curl_setopt($login, CURLOPT_PROXY, $proxy);
    }
    curl_setopt($login, CURLOPT_URL, $url);
    curl_setopt($login, CURLOPT_HEADER, TRUE);
    curl_setopt($login, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
    curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
    curl_setopt($login, CURLOPT_POST, TRUE);
    curl_setopt($login, CURLOPT_POSTFIELDS, '{"username":"mirzazeyrek@gmail.com","password":"mypassword","rememberMe":true,"userip":"213.243.28.145","useragent":"Mozilla/5.0 (Windows; U; Windows NT 6.0; tr; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( )"}');
    ob_start();      // prevent any output
    return curl_exec ($login); // execute the curl command
    ob_end_clean();  // stop preventing output
    curl_close ($login);
    unset($login);    
}               

function curl_grab_page($site,$proxy,$proxystatus){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    if ($proxystatus == 'on') {
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
        curl_setopt($ch, CURLOPT_PROXY, $proxy);
    }
    curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
    curl_setopt($ch, CURLOPT_URL, $site);
    ob_start();      // prevent any output
    return curl_exec ($ch); // execute the curl command
    ob_end_clean();  // stop preventing output
    curl_close ($ch);
}

?>

 

and following code is here:

 

http://www.sozluklerinefendisi.com/mitest.php

 

it isn't working.

 

created cookie.txt is here:

 

# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

www.milliyetemlak.com	FALSE	/	FALSE	1278188457	NSC_fnmblnjmmjzfu	ffffffffd6fb026745525d5f4f58455e445a4a423660

 

any idea ?

 

thanks for looking anyway : )

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.