21,886
社区成员
发帖
与我相关
我的任务
分享
$json_obj = json_decode($result,true);
$access_token = $json_obj['access_token'];
$openid = M("wei_order")->where("TransactionID = '{$ID}'")->getField("openid");
$format = M("wei_order")->where("TransactionID = '{$ID}'")->getField("format");
$total_fee= M("wei_order")->where("TransactionID = '{$ID}'")->getField("total_fee");
//var_dump($format);exit;
$date = date('Y年m月d日 H:i', time());
$post_data =array(
"touser"=>$openid,
"template_id" => "i1-UbLPFJJH5YxS2rpc7t3wHk9shUsrrXR5nsTxyxtQ",
"url" => "http://weixin.qq.com/download",
"data" =>"{ 'first'=>'value':{{'恭喜您购买成功'.DATA}},'color':'#173177',
'format'=>'value':{{'format'.DATA}},'color':'#173177',
'total_fee'=>'value':{{'total_fee'.DATA}},'color':'#173177',
'date'=>'value':{{'date'.DATA}},'color':'#173177',
'remark'=>'value':{{'欢迎再次购买!'.DATA}},'color':'#173177'}"
);
Log::write($post_data);
$data=json_encode($post_data);
Log::write("json数据".$data);
$c = curl_init();
$uri = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=".$access_token;
curl_setopt($c,CURLOPT_URL,$uri);
//curl_setopt($c,CURLOPT_HEADER,0);
curl_setopt($c,CURLOPT_RETURNTRANSFER,1);
curl_setopt($c,CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($c,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($c, CURLOPT_POST, 1);
curl_setopt($c, CURLOPT_POSTFIELDS, $data);
$res = curl_exec($c);
Log::write("通知:".$res);
$post_data =array(
"touser"=>$openid,
"template_id" => "i1-UbLPFJJH5YxS2rpc7t3wHk9shUsrrXR5nsTxyxtQ",
"url" => "http://www.yihang88.cn/index.php/record/getcode",
"data" =>array(
'first'=>array('value'=>'恭喜您购买成功','color'=>'#173177'),
'format'=>array('value'=>$format,'color'=>'#173177'),
'total_fee'=>array('value'=>$total_fee,'color'=>'#173177'),
'date'=>array('value'=>$date,'color'=>'#173177'),
'remark'=>array('value'=>'猛戳我查看所有流量充值记录','color'=>'#173177')
)
);
$post_data = array(
"touser"=>$openid,
"template_id" => "i1-UbLPFJJH5YxS2rpc7t3wHk9shUsrrXR5nsTxyxtQ",
"url" => "http://weixin.qq.com/download",
'data' => array(
'first' => array(
'value' => '恭喜您购买成功',
'color' => '#173177',
),
'keyword1' => array(
'value' => 'xxx商品',
'color' => '#173177',
),
'keyword2' => array(
'value' => '订单号',
'color' => '#173177',
),
'keyword3' => array(
'value' => '156.00元',
'color' => '#173177',
),
'keyword4' => array(
'value' => '2017-05-09 09:40:59',
'color' => '#173177',
),
"remark" => array(
"value" => "感谢您的使用",
"color" => "#173177"
),
),
);
keyword 根据你显示的栏目来