Solved

cUrl https login

Posted on 2008-10-01
9
627 Views
Last Modified: 2012-06-21
Hello experts,
I try to  make a script to login to o2 account at www.o2.ie

I tried this, but it didn't work.
<?php
// new curl object
$data="IDButton=Go&org=o2ext&CONNECTFORMGET=TRUE&IDToken1=myusername&IDToken2=mypass";
$ch = curl_init();
 
// curl options
curl_setopt($ch, CURLOPT_COOKIESESSION, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_URL, "https://www.o2online.ie/amserver/UI/Login"); // URL
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_MAXREDIRS, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"); // Agent
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
 
// exec curl
curl_exec($ch);
 
// download ?! (I know I need a different think to get the file, but the download should be here)
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt");
curl_setopt($ch, CURLOPT_URL, "http://www.o2online.ie/wps/wcm/connect/O2/Logged+in/LoginCheck"); // URL
 
// exec and close
curl_exec($ch);
curl_close($ch);
?>

Thank you for your help
0
Comment
Question by:popolusiak
  • 5
  • 4
9 Comments
 
LVL 9

Expert Comment

by:khaledf
ID: 22629575
does it give any error?
what does curl_exec($ch); return?
0
 
LVL 9

Expert Comment

by:khaledf
ID: 22629587
did you check if this line is having the correct names in O2 form?
IDButton=Go&org=o2ext&CONNECTFORMGET=TRUE&IDToken1=myusername&IDToken2=mypass
0
 
LVL 9

Expert Comment

by:khaledf
ID: 22629595
after executing the code, do you find any file called cookies.txt in your php script folder?
what does cookies.txt contain?
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:popolusiak
ID: 22631861
Thank you for your answer..
I changed postada:
$data="IDButton=Go&org=o2ext&CONNECTFORMGET=TRUE&IDToken1=name&IDToken2=pass&dashboard-login-form-container-login-button=Go
it should by right.

curl_exec($ch) return this site "https://www.o2online.ie/amserver/UI/Login" but it looks diferent(not the same css).

I made "cookies.txt" before a try the script. After the file was empty.

0
 
LVL 9

Accepted Solution

by:
khaledf earned 250 total points
ID: 22633584
I can see only this query string in the O2 website form
$data="IDToken1=name&IDToken2=pass&Go=Go&org=o2ext&gx_charset=UTF-8"

also make sure that cookies.txt file is saved to your server. make sure it has write permission, example change the permissions to 777 for testing purposes.

let me know if this solves your problem
0
 

Author Comment

by:popolusiak
ID: 22638045

You was right. I changend permission to 777 and the cookie file gives this:

# Netscape HTTP Cookie File
# http://curl.haxx.se/rfc/cookie_spec.html
# This file was generated by libcurl! Edit at your own risk.

.o2online.ie      TRUE      /      FALSE      0      o2onlinewebserver      blaecrmiwsp01-ZOyaOAqJwBIAAFrEAogAAACo
www.o2online.ie      FALSE      /      FALSE      0      JSESSIONID_Portal      0000VTU_3Ta1wxjc2L7Sa-E23Ff:118lrhfvm

but curl_exec($ch) return the same output.

sorry about my englis :)


0
 
LVL 9

Expert Comment

by:khaledf
ID: 22638157
can you post the output of curl_exec($ch)
0
 

Author Comment

by:popolusiak
ID: 22638464
Sorry i don't understand. Did you mean source of output.

please
can you try http://humulus.site90.com/main.php?
0
 

Author Comment

by:popolusiak
ID: 22650607
I found the answer thank you for helping..
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

806 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question