473,772 Members | 2,513 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CURL Problem.. Comparing output from IE/CURL differs

I'm writing a tiny php app that will log into our bank of america
account and retrieve a file containing a list of checks that cleared
the previous day. The problem I'm running into is when I perform
actions with php/CURL the output is different than when I use IE and
I'm completely stumped as to why. The final output should list files
available for retrieval but the CURL output displays an error/empty
file message.

Here is the curl portion of my code

global $ERROR_MESSAGE;

$ch = curl_init();
$POSTFIELDS =
"remote=MYLOGIN &password=MYPAS SWORD&Submit=Su bmit&operation= LOGON";

curl_setopt($ch , CURLOPT_RETURNT RANSFER, TRUE);
curl_setopt($ch , CURLOPT_URL,
"https://elink-http4.bankofame rica.com/servlet/MailboxServlet" );
curl_setopt($ch , CURLOPT_SSL_VER IFYPEER, FALSE);
curl_setopt($ch , CURLOPT_USERAGE NT, "Mozilla/4.0 (compatible; MSIE
5.01; Windows NT 5.0)");
curl_setopt($ch , CURLOPT_POST, 1);
curl_setopt($ch , CURLOPT_POSTFIE LDS, "$POSTFIELD S");
curl_setopt($ch , CURLOPT_COOKIEJ AR, "/ReconsileCookie ");

$stuff=curl_exe c($ch);
curl_close($ch) ;

echo $stuff;
$pos = strrpos($stuff, "Logon is successful.");
if ($pos === false)
$ERROR_MESSAGE = "\tUnable to login.\n";

if (curl_errno($ch ))
$ERROR_MESSAGE = "\t" . curl_error($ch) . "\n";
if ($ERROR_MESSAGE == "") { // Login succesfull... Continue retrieval
of file
$ch = curl_init();

$formvars = array();
$formvars["Submit"]="Submit";
$formvars["operation"]="DIRECTORY" ;

curl_setopt($ch , CURLOPT_RETURNT RANSFER, TRUE);
curl_setopt($ch , CURLOPT_URL,
"https://elink-http4.bankofame rica.com/servlet/MailboxServlet" );
curl_setopt($ch , CURLOPT_SSL_VER IFYPEER, FALSE);
curl_setopt($ch , CURLOPT_USERAGE NT, "Mozilla/4.0 (compatible; MSIE
5.01; Windows NT 5.0)");
curl_setopt($ch , CURLOPT_POST, 1);
curl_setopt($ch , CURLOPT_POSTFIE LDS, $formvars);
curl_setopt($ch , CURLOPT_COOKIEF ILE, "/ReconsileCookie ");

$stuff=curl_exe c($ch);
curl_close($ch) ;
echo $stuff;

$pos = strrpos($stuff, "Send is successful.");
if ($pos === false)
$ERROR_MESSAGE ="\tFailed to send edi.txt to bank.\n";
if (curl_errno($ch ))
$ERROR_MESSAGE = "\t" . curl_error($ch) . "\n";

}

Below is the output I get when I execute the above portion of code

<html>
<body>

<HTML>
<HEAD><LINK rel="stylesheet " type="text/css" name="defaultst yle"
href="/cehttp/html/style.css">
<TITLE>Servle t Response Message</TITLE></HEAD>
<BODY>
<H2 align=center>Se rvlet has returned the following message</H2>
<HR>
Logon is successful.
<HR>
</BODY></HTML>
<HTML>
<HEAD><LINK rel="stylesheet " type="text/css" name="defaultst yle"
href="/cehttp/html/style.css">
<TITLE>Servle t Response Message</TITLE></HEAD>
<BODY>
<H2 align=center>Se rvlet has returned the following message</H2>
<HR>
The file is empty or does not exist. Return Code: 701
<HR>
</BODY></HTML>

</body>
</html>
Now, if I use IE to login to the website I recieve

<HTML>
<HEAD><LINK rel="stylesheet " type="text/css" name="defaultst yle"
href="/cehttp/html/style.css">
<TITLE>Servle t Response Message</TITLE></HEAD>
<BODY>
<H2 align=center>Se rvlet has returned the following message</H2>
<HR>
Logon is successful.
<HR>
</BODY></HTML>

After I login I continue with the button to display my file directory
contents and the output is as follows
<HTML><HEAD><LI NK rel="stylesheet " type="text/css" name="defaultst yle"
href="/cehttp/html/style.css">
<TITLE>CONNECT: Enterprise -Directory</TITLE></HEAD>
<BODY>
<CENTER><TABL E BORDER=1>
<CAPTION>CONNEC T:Enterprise Directory Contents</CAPTION>
<TR>
<TH>Mailbox</TH>
<TH>Batch#</TH>
<TH>Size</TH>
<TH>Descripti on (Batch ID)</TH>
<TH>Creation Date</TH>
<TH>Creation Time</TH>
<TH>Flags</TH>
</Table></CENTER>
<CENTER>Numbe r of batches: 0</CENTER>
</BODY></HTML>

Here is the HTML source for the login page.
<HTML>
<HEAD>
<LINK rel="stylesheet " type="text/css"
name="defaultst yle" href="style.css "><TITLE>CONNEC T:Enterprise -
Logon</TITLE>
</HEAD>
<BODY >
<H2>Logon Option</H2>

<FORM METHOD="POST" ACTION="/servlet/MailboxServlet" >

<P><table border=1 cellpadding=4 cellspacing=4
summary="Instru ction box"><tr><td bgcolor="#CC000 0"><font
color="#FFFFFF" ><b>To log on, fill in the necessary fields below and
click on the Submit button.</b></font>
</td></tr>
</table></P>

<table border=0 cellpadding=0 cellspacing=0>
<tr><td>User ID: </td><td><INPUT TYPE="TEXT"
NAME="remote" SIZE="9" MAXLENGTH="64"> </td></tr>
<tr><td>Passwor d:</td><td><INPUT
TYPE="PASSWORD" NAME="password" SIZE="9" MAXLENGTH="16"> </td></tr>

</table>

<P><INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit"
CHECKED="CHECKE D">
<INPUT TYPE="RESET" NAME="Cancel" VALUE="Reset"></P>
<INPUT TYPE="HIDDEN" NAME="operation " VALUE="LOGON">

</FORM>
</BODY>
</HTML>

And here is the source for the 2nd Post data page

<HTML>

<HEAD>
<LINK rel="stylesheet " type="text/css" href="style.css ">
<TITLE>CONNECT: Enterprise - Directory</TITLE>

</HEAD>

<BODY>
<FORM METHOD="POST" ACTION="/servlet/MailboxServlet" >

<H2>Directory Option</h2>

<table border=1 cellpadding=4 cellspacing=4 summary="Instru ction
box"><tr><td bgcolor="CC0000 "><font color="#FFFFFF" ><strong>To see and
download available files, click on the Submit
button.</strong></font></td></tr>
</table>
<br>

<P><INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit" CHECKED="CHECKE D">
<INPUT TYPE="HIDDEN" NAME="operation " VALUE="DIRECTOR Y"></P><br>
</FORM>
</BODY>
</HTML>

Any ideas as to why CURL produces different results? Also I've already
used a CURL based app using almost the identical code above to login
and send a checks cut today file which correctly works..
Thanks
Eric Wescott

Nov 7 '05 #1
6 4267
On 7 Nov 2005 13:51:53 -0800, "Wescotte" <we******@earth link.net> wrote:
curl_setopt($c h, CURLOPT_COOKIEJ AR, "/ReconsileCookie ");


From a brief glance this is the only bit that looked slightly odd - is this a
valid, writable file for the cookie jar?
--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Nov 8 '05 #2
Yes, the cookie itself is correctly created and correctly loaded.
Originally I set it to just "cookie" but I wanted to keep it seperate
so I changed the name to a more recognizable one.

Nov 8 '05 #3
I found the issue..
If I use
curl_setopt($ch , CURLOPT_POSTFIE LDS,
"operation=DIRE CTORY&Submit=Su bmit");

it works
but with

$formvars = array();
$formvars["Submit"]="Submit";
$formvars["operation"]="DIRECTORY" ;
curl_setopt($ch , CURLOPT_POSTFIE LDS, $formsvars);

it does not..
Any idea why?

Nov 9 '05 #4
On 9 Nov 2005 08:55:31 -0800, "Wescotte" <we******@earth link.net> wrote:
I found the issue..
If I use
curl_setopt($c h, CURLOPT_POSTFIE LDS,
"operation=DIR ECTORY&Submit=S ubmit");

it works
but with

$formvars = array();
$formvars["Submit"]="Submit";
$formvars["operation"]="DIRECTORY" ;
curl_setopt($c h, CURLOPT_POSTFIE LDS, $formsvars);

it does not..
Any idea why?


Maybe:

http://cvs.php.net/php-src/ext/curl/interface.c

Particularly look at revisions 1.30 and 1.46 and the bug it references?

It's not exactly well documented when you're supposed to pass as the parameter
when using CURLOPT_POSTFIE LDS.

' CURLOPT_POSTFIE LDS The full data to post in a HTTP "POST" operation.'

This seems to mean the raw POST data as per your first bit of code, but some
versions of the PHP curl extension seem to accept arrays (which is useful).
Looking at the code it appears to accept objects too.
--
Andy Hassall :: an**@andyh.co.u k :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Nov 9 '05 #5
Well, the strange thing is I've used an array before for passing post
data and it worked correctly.

Nov 9 '05 #6
Hello,

on 11/07/2005 07:51 PM Wescotte said the following:
Any ideas as to why CURL produces different results? Also I've already
used a CURL based app using almost the identical code above to login
and send a checks cut today file which correctly works..


I have seen this behaviour with some version of Curl that do not handle
HTTP 1.1 responses with code 100. This is not an error but CUrl could
not handle it properly.

Personally I use this HTTP client class that uses fsockopen with OpenSSL
when available. Otherwise, internally it falls back to curl but changes
the request a bit to avoid the bug. You may want to try the class to see
if it solves your problem too:

http://www.phpclasses.org/httpclient
--

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
Nov 22 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3355
by: D Benfer | last post by:
Hi all, Im a bit thrown by curl. I want to submit some order data on an ecommerce site via a form to a php page, where the data is saved to a database. Then I want to use curl to submit the form data I just saved (and redirect the user) to my secure credit card gateway. Problem is, they have their own secure payment screen where the credit card information is entered. I can't just retrieve the variable with a transaction...
3
6332
by: Chris Fortune | last post by:
# uname -a Linux stargate.mxc-online.net 2.4.20-021stab022.2.777-smp #1 SMP Wed Jul 28 17:12:37 MSD 2004 i686 i686 i386 GNU/Linux I recompiled PHP with mcrypt, openssl, and curl phpinfo(): http://www.canadiandropshipping.com/hello.php3 Does anyone know why this ssl curl test fails? http://www.canadiandropshipping.com...t/diag_curl.php
1
1875
by: lists04 | last post by:
Hi, I have a problem with a curl request and running it under popen2. If I run this request from the command line: curl -i http://www.yahoo.com/test --stderr errfile (also tried redirecting stdderr to a file 2>, nothing) the file errfile is empty indicating no error with the request. However, when I do something similar in python:
9
12598
by: Conrad F | last post by:
Hi, If any Microsoft people are listening.... Are there any plans for the new web language called "Curl" to be supported in .NET (ASP.NET)? I ask as Curl represents the first step to true OO programming of web pages and not just running "scripts" which have in-roads into service DLLs of other languages such as C#. Surely MS will put Curl into .NET at some time since it is designed to work with DirectX and OpenGL?
3
3304
by: Leo | last post by:
Can anyone help or offer some explanation with this problem: I'm trying to do a POST from one of my PHP pages, to another page on my site using curl. To maintain the session I'm sending the current session cookie in the headers using $headerArray = array("Cookie: " . session_name() . "=" . session_id());
2
14688
by: lookee | last post by:
Hello all, I have simple PHP application that on one page strarts session and write some information to it. On another page program tryes to fetch information from a third page using cURL. On that third page program needs to retrive information that were written to the session and use them. Problem is that when I call the third page and call session_start() it starts a new session where there are no infromation I need. Code below. ...
4
12152
by: yawnmoth | last post by:
Is it possible to send http requests with curl but not have curl wait for the response? The reason I ask is because I'd like to code a web app that can sorta start time consuming processes without the user having to wait. I'm doing this (with fsockopen) by sending an http request to a page that does the time consuming stuff and then immediatly closing, without having read any of the response. This way, I don't have to wait for the...
3
2638
by: iskeletor | last post by:
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #define STUDENT_NUMBER 68 #define ARRAY_LENGTH 10 struct node{ char Name,Surname; int data,no;
3
3543
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 prompted to save the php-file, obviously nothing is executed. what i've checked: ..) curl in php works with a selfcompiled php5 binary executed via cgi on the same server
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8937
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7461
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.