Re: POST LOGIN DATA TO AN ASHX PAGE

From: Date: Wed, 07 Jul 2010 23:36:16 +0000
Subject: Re: POST LOGIN DATA TO AN ASHX PAGE
References: 1  Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-8518@lists.php.net to get a copy of this message
Your question seems to have been accidentally posted to the php-webmaster administration list. A better place is the General user list, see http://www.php.net/mailing-lists.php On 07/06/2010 09:02 PM, Mirza Zeyrek wrote:
Hello, I am working about 2-3 days, logining to an ASHX page with using php and curl. I have successfuly logged and getting datas many web sites. So there isn't a problem with my host or codes, i think, at least in theory. But when it comes to ASHX, that's whole different story. I have included post data with LiveHttpHeaders and included php codes too. I have searched many forums and communities but it seems no one has a solution or an idea for this issue. Please Help. "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: 205 Cookie: __utma=183063866.786731720.1278014512.1278466555.1278471227.22; __utmz=183063866.1278459676.19.2.utmcsr=sozluklerinefendisi.com|utmccn=(referral)|utmcmd=referral|utmcct=/mitest.php; __utmb=183063866.4.10.1278471227; __utmc=183063866 Pragma: no-cache Cache-Control: no-cache {"username":"mirzazeyrek@gmail.com","password":"142337","rememberMe":false,"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: ASP.NET_SessionId=stdeiw45udxtqw55sg1lb33h; path=/; HttpOnly Set-Cookie: LoginInfo=; expires=Wed, 07-Jul-2010 02:59:13 GMT; path=/ Set-Cookie: NSC_fnmblnjmmjzfu=ffffffffd6fb025845525d5f4f58455e445a4a423660;expires=Wed, 07-Jul-2010 06:51:59 GMT;path=/;httponly Date: Wed, 07 Jul 2010 02:59:12 GMT" And editted a php code: <?php $veri = "{\"username\":\"mirzazeyrek@gmail.com\",\"password\":\"142337\",\"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 ( )\"}"; echo curl_login(' http://www.milliyetemlak.com/ajaxpro/ArapSabunu,App_Code.nunp_6_w.ashx ',$veri,'','off'); $agent = $_SERVER['HTTP_USER_AGENT']; function curl_login($url,$data,$proxy,$proxystatus){
     $fp = fopen("cookie.txt", "w");
     fclose($fp);
     $login = curl_init();
     curl_setopt($login, CURLOPT_REFERER, "
http://www.milliyetemlak.com/Default.aspx?aType=UyeGiris");
     curl_setopt($login, CURLOPT_COOKIEJAR, "cookie.txt");
     curl_setopt($login, CURLOPT_COOKIEFILE, "cookie.txt");
     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, $agent);
     curl_setopt($login, CURLOPT_FOLLOWLOCATION, TRUE);
     curl_setopt($login, CURLOPT_POST, TRUE);
     ob_start();      // prevent any output
     return curl_exec ($login); // execute the curl command
     ob_end_clean();  // stop preventing output
     curl_close ($login);
     unset($login);
} ?>
-- Email: christopher.jones@oracle.com Tel: +1 650 506 8630 Blog: http://blogs.oracle.com/opal/ Free PHP Book: http://tinyurl.com/ugpomhome

« previous php.webmaster (#8518) next »