Solved

cUrl https login

Posted on 2008-10-01
9
625 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
Comment Utility
does it give any error?
what does curl_exec($ch); return?
0
 
LVL 9

Expert Comment

by:khaledf
Comment Utility
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
Comment Utility
after executing the code, do you find any file called cookies.txt in your php script folder?
what does cookies.txt contain?
0
 

Author Comment

by:popolusiak
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 9

Accepted Solution

by:
khaledf earned 250 total points
Comment Utility
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
Comment Utility

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
Comment Utility
can you post the output of curl_exec($ch)
0
 

Author Comment

by:popolusiak
Comment Utility
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
Comment Utility
I found the answer thank you for helping..
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
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.
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 …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now