我有計劃構建一個自己的財務管理應用程序供個人使用。我通過Chase啓用了直接連接服務,但我有一些問題從服務器獲得響應。這是我正在使用的代碼。有人很高興能夠在另一個論壇上發佈此信息供其他人使用。嘗試使用PHP捲髮送OFX HTTP POST時出錯
<?php
// this function is just used to generate a random transaction id below
function getRandomString($length = 40, $charset = 'alphanum') {
$alpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$num = '';
switch ($charset) {
case 'alpha':
$chars = $alpha;
break;
case 'alphanum':
$chars = $alpha . $num;
break;
case 'num':
$chars = $num;
break;
}
$randstring='';
$maxvalue=strlen($chars)-1;
for ($i = 0; $i < $length; $i++)
$randstring .= substr($chars, rand(0, $maxvalue), 1);
return $randstring;
}
// user login info
$user = 'username';
$pass = 'password';
// account info
$accnt_num = '00000000';
$accnt_type = 'CHECKING';
// date and a random unique transaction id
$txn_id = getRandomString(6);
$tz_offset = date('Z')/3600;
$date = date("YmdHis[$tz_offset:T]");
// Chase info
$org = 'B1';
$fid = '10898';
$bank_id = '122100024';
// transaction retrieval date range
$start_date = '20090101000000'; // from date, to..
$end_date = date('YmdHis'); // now
$xml = "
<OFX>
<SIGNONMSGSRQV1>
<SONRQ>
<DTCLIENT>$date</DTCLIENT>
<USERID>$user</USERID>
<USERPASS>$pass</USERPASS>
<LANGUAGE>ENG</LANGUAGE>
<FI>
<ORG>$org</ORG>
<FID>$fid</FID>
</FI>
<APPID>QWIN</APPID>
<APPVER>2200</APPVER>
</SONRQ>
</SIGNONMSGSRQV1>
<BANKMSGSRQV1>
<STMTTRNRQ>
<TRNUID>$txn_id</TRNUID>
<STMTRQ>
<BANKACCTFROM>
<BANKID>$bank_id</BANKID>
<ACCTID>$accnt_num</ACCTID>
<ACCTTYPE>$accnt_type</ACCTTYPE>
</BANKACCTFROM>
<INCTRAN>
<DTSTART>$start_date</DTSTART>
<DTEND>$end_date</DTEND>
<INCLUDE>Y</INCLUDE>
</INCTRAN>
</STMTRQ>
</STMTTRNRQ>
</BANKMSGSRQV1>
</OFX>";
$ch = curl_init();
$ch1 = curl_setopt($ch, CURLOPT_URL, 'https://ofx.chase.com');
$ch2 = curl_setopt($ch, CURLOPT_POST, 1);
$ch3 = curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
$ch4 = curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
$ch5 = curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ch6 = curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$result = curl_exec($ch);
if ($result) {
echo $result;
}
else
echo "<pre>CURL ERROR: " . curl_error($ch) . "</pre>";
curl_close ($ch);
?>
嘗試從我的瀏覽器運行此命令時,出現以下消息。
CURL ERROR: SSL read: error:00000000:lib(0):func(0):reason(0), errno 0
我在另一篇文章中,您可能需要更新cacert.pem證書,所以我下載了新的一個,並將此向我的php.ini文件,但它並沒有幫助看見。
curl.cainfo = "C:\xampp\PHP\cacert.pem"
如果我使用curl_error的curl_errno代替我得到的56的捲曲的錯誤代碼是CURLE_RECV_ERROR(56)與故障接收網絡數據。
我知道追逐服務器可用於OFX下載,因爲我可以通過GNUCash財務經理獲取我的銀行信息。任何人可以提供幫助將不勝感激。