Solved

cUrl https login

Posted on 2008-10-01
9
636 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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 

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

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Make checkboxes execute queries on click 8 36
xml with php question 5 35
BatchFile-Disk Detection 23 29
form isn't working is it missing a document 21 21
This article discusses how to create an extensible mechanism for linked drop downs.
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

749 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