POST提交地址:https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers
以下是我提交的参数
{"mch_appid":"wx40069cc99024a715","mchid":"1521842141","nonce_str":"TZk45MhOMgWoREwLENurDT2RsL","sign":"dc2af2eee4edbcae6bfe71b71a165de6813ca59e","partner_trade_no":"2019120712540555","openid":"o9TS4uGBPjEEegSm6PUXm1T9Qe74","check_name":"NO_CHECK","amount":"1","desc":"活动推广奖励","spbill_create_ip":"220.202.209.53"}
但是一直返回XML解析错误,请教是什么问题,谢谢!
post 的 body 应为 XML 格式,不能使用 JSON 格式。
$parameters = array(
'appid' => $appid, //小程序ID
'mch_id' => $mch_id, //商户号
'nonce_str' => createNoncestr(), //随机字符串
// 'body' => 'test', //商品描述
'body' => $body,
// 'out_trade_no' => '2015450806125348', //商户订单号
'out_trade_no'=> $out_trade_no,
// 'total_fee' => floatval(0.01 * 100), //总金额 单位 分
'total_fee' => $total_fee,
// 'spbill_create_ip' => $_SERVER['REMOTE_ADDR'], //终端IP
'spbill_create_ip' => '192.168.0.161', //终端IP
'notify_url' => $notify_url, //通知地址 确保外网能正常访问
'openid' => $openid, //用户id
'trade_type' => 'JSAPI'//交易类型
);
//数组转换成xml
function arrayToXml($arr) {
$xml = "<root>";
foreach ($arr as $key => $val) {
if (is_array($val)) {
$xml .= "<" . $key . ">" . arrayToXml($val) . "</" . $key . ">";
} else {
$xml .= "<" . $key . ">" . $val . "</" . $key . ">";
}
}
$xml .= "</root>";
return $xml;
}
PHP得代码 但愿对你有帮助
支付、卡券相关的问题请移步至微信支付专区https://developers.weixin.qq.com/community/pay提问,我们会有对应同学来处理,此贴先隐藏,请重新发帖咨询。