Solved

cUrl https login

Posted on 2008-10-01
9
641 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

728 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