//发送红包start $url = 'https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack'; //获取openID $uid = $list['uid']; $result = pdo_fetch("SELECT openid FROM ims_meepo_online_user WHERE id=:id",array(':id'=>$uid)); $open_id = $result['openid']; $money = (float)$list['money']; $package = array(); $package['nonce_str'] = random(8); $package['mch_billno'] = 'xxx'.rand(10000000000000,99999999999999); $package['mch_id'] = '1515256111'; $package['wxappid'] = 'wx57a837f1e72026c3'; $package['send_name'] = 'xxxx'; $package['re_openid'] = $open_id; $package['total_amount'] = $money*100; $package['total_num'] = 1; $package['wishing'] = 'xxxx佣金'.date('Y-m-d'); $package['client_ip'] = CLIENT_IP; $package['act_name'] = 'xxxxx佣金'; $package['remark'] = '根据会员后台提现的金额返佣.'; $package['scene_id'] = 'PRODUCT_5'; ksort($package, SORT_STRING); $string1 = ''; foreach($package as $key => $v) { if (empty($v)) { continue; } $string1 .= "{$key}={$v}"; } $string1 .= "key=2nHuHsDijB4Ye7mNN22QxFAP3AW6l3hT"; $package['sign'] = strtoupper(md5($string1)); $dat = array2xml($package); load()->func('communication'); $certPath = 'E:\xxxxx/apiclient_cert.pem'; $keyPath = 'E:\xxxxx\cert/apiclient_key.pem'; $extra = array( CURLOPT_SSL_VERIFYPEER=>false, CURLOPT_SSL_VERIFYHOST=>false, CURLOPT_SSLCERTTYPE=>'PEM', CURLOPT_SSLKEYTYPE=>'PEM', CURLOPT_SSLCERT=>$certPath, CURLOPT_SSLKEY=>$keyPath, CURLOPT_POST=>1 ); $response = ihttp_request($url, $dat, $extra); if($response['errno'] == 58){ $err_msg = $response['message']; die(json_encode(error('-1',$err_msg))); }else{ $xml = $response['content']; $result = xml2array($xml); if($result['result_code'] == 'SUCCESS'){ $pdo_list = pdo_update("meepo_online_money_page",array('order_static'=>$is_best),array('id'=>$id)); die(json_encode(error('0','success'))); }else if($result['result_code'] == 'FAIL'){ //alert error $err_msg = $result['return_msg']; die(json_encode(error('-1',$err_msg))); } } //exit; //echo $response; //发送红包end