diff --git a/mobile/blank.php b/mobile/blank.php index 9efede6..7149743 100644 --- a/mobile/blank.php +++ b/mobile/blank.php @@ -53,45 +53,6 @@ $_SESSION['openid'] = $openid; $_SESSION['access_token'] = $$access_token; // echo $openid; -// test_sc -// 构造模板消息内容 -$template_data = array( - 'touser' => $openid, - 'template_id' => $template_id, - 'url' => '', //点击模板消息跳转的URL - 'data' => array( - 'key1' => array('value' => 'value1'), - 'key2' => array('value' => 'value2'), - 'key3' => array('value' => 'value3'), - ), -); - -// 发送模板消息 -$url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=' . $access_token; - -$ch = curl_init(); -curl_setopt($ch, CURLOPT_URL, $url); -curl_setopt($ch, CURLOPT_POST, 1); -curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($template_data)); -curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); -$response = curl_exec($ch); -curl_close($ch); - -// 处理响应结果 -if ($response === false) { - // 模板消息发送失败 - echo '发送模板消息失败!'; -} else { - $result = json_decode($response, true); - if ($result['errcode'] == 0) { - // 模板消息发送成功 - echo '发送模板消息成功!'; - } else { - // 模板消息发送失败 - echo '发送模板消息失败!' . $result['errmsg']; - } -} - header('Location: ' . $referer); exit; // 用户授权成功,这里可以将用户信息保存到数据库中,或者进行其他操作 diff --git a/mobile/plugins/payment/wxnotify.php b/mobile/plugins/payment/wxnotify.php index 60163bc..335a575 100644 --- a/mobile/plugins/payment/wxnotify.php +++ b/mobile/plugins/payment/wxnotify.php @@ -28,6 +28,49 @@ // // ... // } session_start(); +$openid = $_SESSION['openid']; +$template_id = '5JCt5gNGM7sfwWnRqwWsjH138DixCFJ7sPEbToYQAmQ'; +$access_token = $_SESSION['access_token']; + +// test_sc +// 构造模板消息内容 +$template_data = array( + 'touser' => $openid, + 'template_id' => $template_id, + 'url' => '', //点击模板消息跳转的URL + 'data' => array( + 'key1' => array('value' => 'value1'), + 'key2' => array('value' => 'value2'), + 'key3' => array('value' => 'value3'), + ), +); + +// 发送模板消息 +$url = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=' . $access_token; + +$ch = curl_init(); +curl_setopt($ch, CURLOPT_URL, $url); +curl_setopt($ch, CURLOPT_POST, 1); +curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($template_data)); +curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); +$response = curl_exec($ch); +curl_close($ch); + +// 处理响应结果 +if ($response === false) { + // 模板消息发送失败 + echo '发送模板消息失败!'; +} else { + $result = json_decode($response, true); + if ($result['errcode'] == 0) { + // 模板消息发送成功 + echo '发送模板消息成功!'; + } else { + // 模板消息发送失败 + echo '发送模板消息失败!' . $result['errmsg']; + } +} + $logFilePath = './wxlogde_decrypt.txt'; // 日志文件保存路径 file_put_contents($logFilePath, "new begin:\n\r", FILE_APPEND | LOCK_EX);