In order to grab the schedule for a particular class I now have to visit a different area of the university site, the registrar. The course schedule section of the registrar is coded in ASP .net and I'm having trouble making HTTP requests to this area of the site.
I understand the need to make post requests to mimic the Viewstate but I'm running into an issue before I even get to that part.
I am able to load the page via an HTTP request almost every time. But it always takes almost exactly 2 minutes. I have tried simple get requests, post requests with the Viewstate, and other variations to one of a few different pages on the site. Each time it works. But each time it takes 2 minutes.
Any ideas why it takes so long? Any suggestions on what I can possibly do differently?
Here is the basic site I'm using to test my code on before implementing it fully into my program:
University Site
Here is my link that takes 2 minutes to load the same page:
My Site
Here is my latest code I've tried:
Code: Select all
<?php
$postdata = "__VIEWSTATE=/wEPDwULLTIwNjY2MzUzMDEPZBYCAgUPDxYCHgRUZXh0BRNNYXIgMjMgMjAxMSAgNzoxNVBNZGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFDmN0bDEwJGltZ0xvZ2luaYy4H4gz+Bjb4GVdsO1ecd9c9EA=";
$postdata .= "&__EVENTVALIDATION=/wEWAgKs/IaWBAKpyP2zAXWcNEO0tMqDX53r6m+Hzo/nKHwZ";
$postdata = urlencode($postdata);
$host = 'courseschedules.njit.edu';
$path = '/index.aspx';
$fp1 = fsockopen($host,80,$errno,$errstr,30);
if(!$fp1)
die($_err.$errstr.$errno);
else
{
fputs($fp1, "POST $path HTTP/1.1\r\n");
fputs($fp1, "Host: $host\r\n");
fputs($fp1, "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Firefox/3.6.15 ( .NET CLR 3.5.30729)\r\n");
fputs($fp1, "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n");
fputs($fp1, "Accept-Language: en-us,en;q=0.5\r\n");
fputs($fp1, "Accept-Encoding: gzip,deflate\r\n");
fputs($fp1, "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n");
fputs($fp1, "Keep-Alive: 115\r\n");
fputs($fp1, "Connection: keep-alive\r\n");
fputs($fp1, "Content-length: ".strlen($postdata)."\r\n\r\n");
fputs($fp1, $postdata."\r\n\r\n");
$response = '';
while(!feof($fp1)) $response .= fgets($fp1,2000);
fclose($fp1);
echo $response;
}
?>