Solved

cUrl https login

Posted on 2008-10-01
9
643 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Command Line Tips and Tricks

The command line is a powerful tool at the disposal of every Linux user. Although Linux distros come with beautiful user interfaces, it's worthwhile to learn the command line because it allows you to do a number of things that you otherwise cannot do from the GUI.  

 

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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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 …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

632 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