php實現浦發銀企直連8804轉賬查詢


????本案例爲浦發銀企直連查詢當天的一筆轉賬記錄,受理編號爲“PT19YQ0000136591”。

????代碼如下

$data?=?'

101952A99972200080922019110720191107PT19YQ00001365912010

';

$data=iconv("UTF-8","gbk//TRANSLIT",$data);

$xml?=?curlPost($data,"127.0.0.1:4437","INFOSEC_SIGN/1.0");
$need?=?getNeedBetween($xml,?'',?'');

$xml?=?"
44021110711445920000407522019-11-07?11:44:59"?.?$need?.?"";
$len?=?str_pad(6?+?strlen($xml),?6,?"0",?STR_PAD_LEFT);
$xml=$len.$xml;
$res=curlPost($xml,"127.0.0.1:5777","text/plain");

$sign?=?getNeedBetween($res,?'ature>',?'');
$info=curlPost($sign,"127.0.0.1:4437","INFOSEC_VERIFY_SIGN/1.0");
$info=getNeedBetween($info,?'');
var_dump(xmlToArray(""));exit;

function?curlPost($data,$url,$type)
{
????$ch?=?curl_init();
????curl_setopt($ch,?CURLOPT_URL,?$url);
????curl_setopt($ch,?CURLOPT_POST,?1);
????curl_setopt($ch,?CURLOPT_CONNECTTIMEOUT,?60);
????curl_setopt($ch,?CURLOPT_HTTPHEADER,?array('Content-Type:?'.$type));
????curl_setopt($ch,?CURLOPT_POSTFIELDS,?$data);
????curl_setopt($ch,?CURLOPT_RETURNTRANSFER,?1);
????$output?=?curl_exec($ch);
????return?$output;
????curl_close($ch);
}

function?getNeedBetween($kw1,?$mark1,?$mark2)
{
????$kw?=?$kw1;
????$st?=?stripos($kw,?$mark1);
????$ed?=?stripos($kw,?$mark2);
????if?(($st?==?false?||?$ed?==?false)?||?$st?>=?$ed)
????????return?0;
????$kw?=?substr($kw,?($st?+?6),?($ed?-?$st?-?6));
????return?$kw;
}

function?xmlToArray($xml)
{
????libxml_disable_entity_loader(true);
????$values?=?json_decode(json_encode(simplexml_load_string($xml,?'SimpleXMLElement',?LIBXML_NOCDATA)),?true);
????return?$values;
}



評論


乖,登錄后才可以留言!