You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/api/controller/Wxserver.php

52 lines
1.8 KiB

11 months ago
<?php
11 months ago
declare (strict_types=1);
11 months ago
namespace app\api\controller;
use cores\BaseController;
11 months ago
use think\facade\Db;
11 months ago
use think\response\Json;
11 months ago
class Wxserver extends BaseController
11 months ago
{
public function index(): Json
{
11 months ago
$obj = new \app\common\library\wxserver\Server();
$url = $this->request->domain(true) . '/api/wxserver/redirect';
$jumUrl = $obj->jumpH5Url($url);
return $this->renderSuccess(compact('jumUrl'));
11 months ago
}
public function verifyTicket()
{
11 months ago
$xmlData = file_get_contents("php://input");
$obj = new \app\common\library\wxserver\Server();
$obj->getVerifyTicket($xmlData);
11 months ago
echo 'success';
}
11 months ago
public function redirect()
{
11 months ago
$authorization_code = $this->request->get('auth_code');
11 months ago
$expires_in = $this->request->get('expires_in');
11 months ago
$data = $this->request->input();
$datas = $this->request->get();
if ($datas) {
if (is_array($datas)) {
$datas = json_encode($datas);
}
Db::table('yoshop_wx_server')->insertGetId(['content' => '回调数据get&' . $datas . $authorization_code, 'created_at' => date('Y-m-d H:i:s')]);
}
if ($data) {
if (is_array($data)) {
$data = json_encode($data);
}
Db::table('yoshop_wx_server')->insertGetId(['content' => '回调数据input&' . $data . $authorization_code, 'created_at' => date('Y-m-d H:i:s')]);
}
11 months ago
Db::table('yoshop_wx_server')->insertGetId(['content' => '回调授权地址' . $authorization_code, 'created_at' => date('Y-m-d H:i:s')]);
11 months ago
if ($authorization_code) {
$obj = new \app\common\library\wxserver\Server();
$obj->authorizationInfo($authorization_code);
}
}
11 months ago
}