cURL login problem for a licensed webpage [message #175547] |
Thu, 06 October 2011 12:23 |
tokiyashi
Messages: 2 Registered: October 2011
Karma: 0
|
Junior Member |
|
|
Hey guys, i'm writing a simple code piece to create a little
application for our university and i need to login our university's
data management system.
I wrote code below there, i don't know what is going wrong. login.aspx
page includes the login form. dashboard.aspx is what i want to get.
$url = "https://bys.marmara.edu.tr/login.aspx";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
//curl_setopt($ch,
CURLOPT_POSTFIELDS,'txtLogin='.urlencode($username).'&txtPassword='.url encode($password));
curl_setopt($ch, CURLOPT_POSTFIELDS,'txtLogin='.
$username.'&txtPassword='.$password);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_exec($ch);
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_URL, 'http://bys.marmara.edu.tr/
dashboard.aspx');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($ch);
echo $page;
with best regards,
Çağlar Bozkurt / tokiyashi
|
|
|
Re: cURL login problem for a licensed webpage [message #175548 is a reply to message #175547] |
Thu, 06 October 2011 12:37 |
tokiyashi
Messages: 2 Registered: October 2011
Karma: 0
|
Junior Member |
|
|
I added license too, but still not working.
$url = "https://bys.marmara.edu.tr/login.aspx";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch,
CURLOPT_POSTFIELDS,'txtLogin='.urlencode($username).'&txtPassword='.url encode($password));
//curl_setopt($ch, CURLOPT_POSTFIELDS,'txtLogin='.
$username.'&txtPassword='.$password);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_CAINFO, "./bys-license.crt");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_COOKIEJAR, "my_cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "my_cookies.txt");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows
NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
curl_exec($ch);
curl_close($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_URL, 'http://bys.marmara.edu.tr/
dashboard.aspx');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
|
|
|
Re: cURL login problem for a licensed webpage [message #175550 is a reply to message #175547] |
Thu, 06 October 2011 18:52 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma: 0
|
Senior Member |
|
|
On Thu, 06 Oct 2011 05:23:41 -0700, Çağlar Bozkurt wrote:
> Hey guys, i'm writing a simple code piece to create a little application
> for our university and i need to login our university's data management
> system.
Step back and apply some thought.
How does the web site, once you have logged into it, normally identify
that, from one http to the request, it is talking to the same client?
I would imagine that the website is presenting credentials to the browser
following a successful login, either using a value set in a hidden form
field, or setting a cookie, and then expecting the browser to use these
credentials to subsequently identify the user "session" to the website.
You will need to determine exactly how the website does this, and set
your curl calls up appropriately to retrieve and present such
"credentials" after "logging in".
Rgds
Denis McMahon
|
|
|