You are here: CURL Problem.. Comparing output from IE/CURL differs « PHP Programming Language « IT news, forums, messages
CURL Problem.. Comparing output from IE/CURL differs

Posted by Wescotte on 11/06/13 11:31

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=MYPASSWORD&Submit=Submit&operation=LOGON";

curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL,
"https://elink-http4.bankofamerica.com/servlet/MailboxServlet");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE
5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$POSTFIELDS");
curl_setopt($ch, CURLOPT_COOKIEJAR, "/ReconsileCookie");

$stuff=curl_exec($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_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL,
"https://elink-http4.bankofamerica.com/servlet/MailboxServlet");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE
5.01; Windows NT 5.0)");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $formvars);
curl_setopt($ch, CURLOPT_COOKIEFILE, "/ReconsileCookie");

$stuff=curl_exec($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="defaultstyle"
href="/cehttp/html/style.css">
<TITLE>Servlet Response Message</TITLE></HEAD>
<BODY>
<H2 align=center>Servlet has returned the following message</H2>
<HR>
Logon is successful.
<HR>
</BODY></HTML>
<HTML>
<HEAD><LINK rel="stylesheet" type="text/css" name="defaultstyle"
href="/cehttp/html/style.css">
<TITLE>Servlet Response Message</TITLE></HEAD>
<BODY>
<H2 align=center>Servlet 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="defaultstyle"
href="/cehttp/html/style.css">
<TITLE>Servlet Response Message</TITLE></HEAD>
<BODY>
<H2 align=center>Servlet 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><LINK rel="stylesheet" type="text/css" name="defaultstyle"
href="/cehttp/html/style.css">
<TITLE>CONNECT:Enterprise -Directory</TITLE></HEAD>
<BODY>
<CENTER><TABLE BORDER=1>
<CAPTION>CONNECT:Enterprise Directory Contents</CAPTION>
<TR>
<TH>Mailbox</TH>
<TH>Batch#</TH>
<TH>Size</TH>
<TH>Description (Batch ID)</TH>
<TH>Creation Date</TH>
<TH>Creation Time</TH>
<TH>Flags</TH>
</Table></CENTER>
<CENTER>Number of batches: 0</CENTER>
</BODY></HTML>



Here is the HTML source for the login page.


<HTML>
<HEAD>
<LINK rel="stylesheet" type="text/css"
name="defaultstyle" href="style.css"><TITLE>CONNECT:Enterprise -
Logon</TITLE>
</HEAD>
<BODY >


<H2>Logon Option</H2>

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

<P><table border=1 cellpadding=4 cellspacing=4
summary="Instruction box"><tr><td bgcolor="#CC0000"><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>Password:</td><td><INPUT
TYPE="PASSWORD" NAME="password" SIZE="9" MAXLENGTH="16"></td></tr>

</table>

<P><INPUT TYPE="SUBMIT" NAME="Submit" VALUE="Submit"
CHECKED="CHECKED">
<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="Instruction
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="CHECKED">
<INPUT TYPE="HIDDEN" NAME="operation" VALUE="DIRECTORY"></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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация