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