Topic: Connecting to USAA using PHP

I'm having some trouble connecting to USAA to grab transactions. I'm using PHP and cURL to send the OFX request to USAA, but I get the following warning message from USAA:

We are unable to complete your request (4645859375844275642)

The page you requested could not be displayed. This may be due to an incorrect link or a system error.
Please make sure you entered the web address correctly or try back again later.

If you need additional help, contact Website Technical Support at 1-877-632-3002.



Click your browser's "back" button to return to the previous page.

Here is the PHP code that I am using to try to connect:

<?php
$date = date("YmdHis");
    
$url = "https://service2.usaa.com/ofx/OFXServlet";
    
$post_string = "<OFX>
<SIGNONMSGSRQV1>
<SONRQ>
<DTCLIENT>$date
<USERID>user#
<USERPASS>pass#
<LANGUAGE>ENG
<FI>
<ORG>USAA
<FID>24591
</FI>
<APPID>TESTPHP
<APPVER>0100
</SONRQ>
</SIGNONMSGSRQV1>
<BANKMSGSRQV1>
<STMTTRNRQ>
<TRNUID>1001
<STMTRQ>
<BANKACCTFROM>
<BANKID>314074269
<ACCTID>account#
<ACCTTYPE>CHECKING
</BANKACCTFROM>
<INCTRAN>
<INCLUDE>Y
</INCTRAN>
</STMTRQ>
</STMTTRNRQ>
</BANKMSGSRQV1>
</OFX>";

$header2 = "\r\n";
$header2 .= "OFXHEADER:100\r\n";
$header2 .= "DATA:OFXSGML\r\n";
$header2 .= "VERSION:102\r\n";
$header2 .= "SECURITY:NONE\r\n";
$header2 .= "ENCODING:USASCII\r\n";
$header2 .= "CHARSET:UTF-8\r\n";
$header2 .= "COMPRESSION:NONE\r\n";
$header2 .= "OLDFILEUID:NONE\r\n";
$header2 .= "NEWFILEUID:NONE\r\n";
$header2 .= "\r\n";
$header2 .= $post_string;

$header = "POST https://service2.usaa.com/ofx/OFXServlet HTTP/1.0 \r\n";
$header .= "User-agent: TESTPHP \r\n";
$header .= "Content-type: application/x-ofx \r\n";
$header .= "Content-length: " . strlen($header2) . " \r\n";
$header .= $header2;
    
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
    
$data = curl_exec($ch);
    
if(curl_errno($ch))
    print curl_error($ch);
else
    curl_close($ch);
        
echo $data;
?>

Using the same settings, I can connect just fine using GnuCash, so it must be some problem with my code listed above.