~~~
<?php
header("Content-Type:text/html; charset=utf-8");
//檢測是否支持cURL
if(!extension_loaded('curl'))
{
trigger_error('對不起,請開啟curl功能模塊!', E_USER_ERROR);
}
$ip=$_SERVER["REMOTE_ADDR"];
//$ip="127.0.0.1";
$str="body=測試支付&mch_create_ip=".$ip."&mch_id=100004383076&nonce_str=1409196838¬ify_url=http://www.baidu.com&out_trade_no=141903606228&service=pay.weixin.jspay&total_fee=1&key=0180437CED486F857078875D3039CC59";
$str1= strtoupper(md5($str));
//echo $str1;exit();
//構造xml
$xmldata = <<<xml
<?xml version='1.0' encoding='UTF-8'?>
<xml>
<body><![CDATA[測試支付]]></body>
<mch_create_ip><![CDATA[$ip]]></mch_create_ip>
<mch_id><![CDATA[100004383076]]></mch_id>
<nonce_str><![CDATA[1409196838]]></nonce_str>
<notify_url><![CDATA[http://www.baidu.com]]></notify_url>
<out_trade_no><![CDATA[141903606228]]></out_trade_no>
<service><![CDATA[pay.weixin.jspay]]></service>
<sign><![CDATA[$str1]]></sign>
<total_fee><![CDATA[1]]></total_fee>
</xml>
xml;
//初始化curl會話
$ch = curl_init();
//設置url
curl_setopt($ch, CURLOPT_URL, 'http://mapi.bosc.uline.cc/unionpay/staticquery');
//設置發送方式
curl_setopt($ch, CURLOPT_POST, true);
//設置發送的數據
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmldata);
//抓取URL并把它傳遞給瀏覽器
curl_exec($ch);
//關閉cURL資源,并且釋放系統資源
curl_close($ch);
?>
~~~