PHP Curl into ASPX website

Hey, I have sister websites, one of them is with a CM system in aspx ( do not have access to source code ). I'm trying to login and scrape from a list, but just.. nothing happens, no error.. any help would be wonderful. I've tested the script on non-aspx logins and it works fine, I've tried it using the EVENTSTATE and EVENTVALIDATION variables there or not.
$strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
	session_write_close();

	$agent="Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";

	// Login

	$back = 'txtUsername=[username]&txtPassword=[password]&chkRememberMe=on&btnSubmit=Login';
	$back .= "&__EVENTVALIDATION=/wEWBQLTg7DMBQKl1bK4CQK1qbSRCwLC8qqaCgLCi9reA/HCC7Z/TFEFxbmdxzpyokLktjos";
	$back.= "&__EVENTSTATE/wEPDwULLTEyMTcwMTQ3MDFkGAEFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQ1jaGtSZW1lbWJlck1l+uyKxry09hPIkqVla98roCW+U9k=";
	$back_url = "[login url];
	
	$url=$back_url;
	$vars=$back;

	 $options = array(
		CURLOPT_REFERER => $back_url,
        CURLOPT_RETURNTRANSFER => true,     // return web page
        CURLOPT_HEADER         => false,    // don't return headers
        CURLOPT_FOLLOWLOCATION => true,     // follow redirects
        CURLOPT_ENCODING       => "",       // handle all encodings
        CURLOPT_AUTOREFERER    => true,     // set referer on redirect
        CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
        CURLOPT_TIMEOUT        => 120,      // timeout on response
        CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
		CURLOPT_POST		   =>1,
		CURLOPT_POSTFIELDS		=> $vars ,
		CURLOPT_COOKIEJAR	=> 'cookie.txt',
		CURLOPT_COOKIEFILE => 'cookie.txt',
		CURLOPT_SSL_VERIFYHOST => 0,
		CURLOPT_SSL_VERIFYPEER => 0,
		CURLOPT_USERAGENT => $agent,
		CURLOPT_COOKIE => $strCookie 
    );

    $ch      = curl_init( $url );

    curl_setopt_array( $ch, $options );

    $content = curl_exec( $ch );
    $err     = curl_errno( $ch );
    $errmsg  = curl_error( $ch );
    $header  = curl_getinfo( $ch );
    curl_close( $ch );

Open in new window

WhistlingMtnAsked:
Who is Participating?
 
p_nutsCommented:
have a go at it with snoopy..
http://sourceforge.net/projects/snoopy/
that does all the curl stuff for you.. much easier to use a class that works instead of having to re-invent the wheel.
P_nuts
0
 
WhistlingMtnAuthor Commented:
I've never heard of it. I'll try it out later today.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
WhistlingMtnAuthor Commented:
Snoopy really doesn't have the greatest documentation, I can't seem to get it to work even with the logins I have working with libcurl. There doesn't seem to be an option to set the cookie file, do you know of an example somewhere of a snoopy login?
0
 
WhistlingMtnAuthor Commented:
Yea, I can't get it to work, I think I'll stick with the libcurl, at least I know I have that working on other logins.
0
 
WhistlingMtnAuthor Commented:
Ok, one step further, using the livehttpheaders plugin for Firefox I was able to direct grab the post vars from logging on, they must have had to be in a specific order. The cookie is created after login, but it doesn't seem to retain the session.. so onto that.
0
 
WhistlingMtnAuthor Commented:
Hmm, I think it's not working because one of the set-cookie is "Secure"
0
 
WhistlingMtnAuthor Commented:
Ok, I have a tentative success. I pulled the set-cookie line from the headers returned and appended it to the cookie file, and the first couple tests, successful!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.