473,322 Members | 1,494 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Problem with PHP CURL script

Hello,

I am trying to access a website which is hosted on secure server. Code looks as follows,

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. //open connection   
  4. $ch = curl_init();   
  5.  
  6. //set the url, number of POST vars, POST data   
  7. curl_setopt($ch,CURLOPT_URL,"http://web2.westlaw.com/signon/default.wl");
  8. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);
  9. curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)");
  10. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  11. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  12.  
  13. //execute post   
  14. $result = curl_exec($ch);   
  15.  
  16. //close connection   
  17. curl_close($ch);
  18.  
  19. echo $result;
  20.  
  21. ?>
This web page has a redirect javascript at top which detects frame name and if no frame is found, the page is redirected using "location.href" method.

Due to this method, the page is refreshed but with the local address i.e. http://localhost:8080/test_project/signon/default.wl and hence, it gives, page cannot be found error. How can I overcome this problem ?

Thanks,
Sandeep
Aug 27 '08 #1
4 4817
Atli
5,058 Expert 4TB
Hi.

I may be wrong here, but I don't think a Javascript redirect would have any effect on a Curl request.
Javascript is executed client-side, which would require a browser capable of executing Javascript code.
As far as I know, Curl would simply return the Javascript code as plain text.

One thing about that code...
Shouldn't a request to a secure page start with https?
Aug 28 '08 #2
Hi Atli,

Thanks for the reply :)

I am pointing to 'https' website. That's a typo in my post.

Regarding javascript redirect, I was referring to the action after CURL script execution. I'll put forward some more description about my script.

I am executing script on local server as,
http://localhost:8080/test_project/test_curl.php

I am pointing to 'https://web2.westlaw.com/signon/default.wl' through CURL. When I execute the script, browser address bar shows,
http://localhost:8080/signon/default.wl

As you can see, URL part next to domain name is appended over here (signon/default.wl) That's why, I was thinking that the page on Westlaw was submitting to itself. If you do view->source on 'https://web2.westlaw.com/signon/default.wl', you would see following code at top.

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. <!--
  3.     var getCorrectFN = null;
  4.     if (document.referrer != '') {
  5.         getCorrectFN = document.referrer;
  6.         getCorrectFN = getFrameName(getCorrectFN);
  7.     }
  8.  
  9.     if (getCorrectFN == "_top" || getCorrectFN == "WestlawFrameWithChat" || getCorrectFN == "%5Ftop") {
  10.         if (top.location != location) {
  11.             top.location.href = location.href;
  12.         }
  13.     }
  14.     else if (getCorrectFN != null && getCorrectFN.length > 0) {
  15.         getWestlawFrameReference(getCorrectFN).location.href = location.href;
  16.     }
  17.     if (window.parent == window) {
  18.         if (top.name != "FromEW") {
  19.             top.name = '';
  20.         }
  21.     }
  22. //-->
  23. </script>
One more observation. When you open 'https://web2.westlaw.com/signon/default.wl', a small blank popup opens in right bottom corner which closes itself within 5-10 seconds. When I execute my script, a popup opens with same 'Page cannot be found' error as in the parent window.

I hope, I have explained the problem in a better way now.

Thanks,
Sandeep
Aug 29 '08 #3
Atli
5,058 Expert 4TB
Why does the URI change after the Curl code has been executed?
Do you echo the result you get from Curl?

As far as I know, Curl shouldn't do anything with the code it gets from the response. Any Javascript would be stored as text, only executed if you decide to use it.

So, we can't really know why this is happening unless we know what your PHP code is doing.
It would really help if we could see that code.
Aug 30 '08 #4
Hi Atli,

I have already posted the code. That's the only piece of code, I have.

Could this be due to some session check on website. I am saying so because even if I JUST try to access the website with CURL script (without the post arguments), same action takes place and browser shows "Page cannot be found".

Thanks,
Sandeep
Aug 31 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: machodev | last post by:
Hello Friends, Getting a bit fuzzy on the Authorize.net and the Curl Integration. I have the script using the for the authorize.net Integration with the curl command exec("/usr/local/bin -m...
1
by: Bib | last post by:
I'm working on a box that allegedly has curl support, but when I run a script that access curl, I get this error: Fatal error: Call to undefined function: curl_init() in...
0
by: Phil Powell | last post by:
What is the most standardized method of utilizing the CURL functions in PHP (version 4.3.2) to be able to retrieve the contents of a remote URL that happens to be dependent upon $_SESSION for its...
3
by: Hans | last post by:
Hi everybody, I am desperately trying to log into my account at godaddy.com with PHP and Curl and just cannot make it happen. Has anybody written a script for this purpose? Here is what I...
0
by: nfhm2k | last post by:
I've been trying to find a solution to this for quite some time now... I even took a look at existing scripts... Including this one......
15
by: Bob Bedford | last post by:
Hi all, I'm having troubles with my hosting and for a few reasons I can't change. So here is my problem: I receive XML files with images included in the file. I've to parse the file, save datas...
4
by: Terry | last post by:
I'm using curl to invoke a php script on the same site/server. It works great, but if I call it again while it's still running, nothing happens. Why? Can that be fixed? Why use curl? To make...
3
by: Matthias Leopold | last post by:
hi i've got problems getting php4 scripts which use curl to work on RHEL4 (Nahant Update 4) and CentOS 4.4. when the script is accessed the browser "hangs", after a couple of minutes i'm...
11
by: Flexor | last post by:
I have a php script that runs from command line and makes an https request to paypal, using curl. It works fine if I run it from a web page. It fails if I run it from CLI. The error I get from...
3
by: jeddiki | last post by:
I am using curl to down load a zip file and I am then trying to unzip it, but I don't think that I am using the functions properly because I get warnings This is my code: <?php if...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.