3,143
社区成员
发帖
与我相关
我的任务
分享
$url = "https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack";
$nowtime = mktime();
$nowtime_ymd = $mch_id . date('Ymd') . substr(time(), -1) . substr(microtime(), 2, 8);
$mch_billno = $nowtime_ymd;
$nick_name = "你好";
$send_name = "你好的";
$re_openid = $user_openid;
$min_value = $total_amount;
$max_value = $total_amount;
$total_num = 1;
$wishing = "感谢您的参与";
$client_ip = $_SERVER["REMOTE_ADDR"];
$act_name = "欢迎光临";
$remark = "case";
$nonce_str = $this->randstr(32);
$post_sign_arr = array(
"nonce_str" => $nonce_str,
"mch_billno" => $mch_billno,
"mch_id" => $mch_id,
"wxappid" => $wxappid,
"nick_name" => $nick_name,
"send_name" => $send_name,
"re_openid" => $re_openid,
"total_amount" => $total_amount,
"min_value" => $min_value,
"max_value" => $max_value,
"total_num" => $total_num,
"wishing" => $wishing,
"client_ip" => $client_ip,
"act_name" => $act_name,
"remark" => $remark,);
$post_sign = $this->sign($post_sign_arr);
$post_data = array("nonce_str" => $nonce_str, "sign" => $post_sign, "mch_billno" => $mch_billno, "mch_id" => $mch_id, "wxappid" => $wxappid, "nick_name" => $nick_name, "send_name" => $send_name, "re_openid" => $re_openid, "total_amount" => $total_amount, "min_value" => $min_value, "max_value" => $max_value, "total_num" => $total_num, "wishing" => $wishing, "client_ip" => $client_ip, "act_name" => $act_name, "remark" => $remark);
$post_data_xml = $this->gen_xml($post_data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSLCERT, '/home/wwwroot/sick/cert/apiclient_cert.pem');
curl_setopt($ch, CURLOPT_SSLKEY, '/home/wwwroot/sick/cert/apiclient_key.pem');
curl_setopt($ch, CURLOPT_CAINFO, '/home/wwwroot/sick/cert/rootca.pem');
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// post数据
curl_setopt($ch, CURLOPT_POST, 1);
// post的变量
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data_xml);
$output = curl_exec($ch);
$this->loginfo("红包发放返回数据:" . $output);
curl_close($ch);
return $output;
}