当前位置:网站首页>Crmeb multi merchant system applet authorization problem solving paste
Crmeb multi merchant system applet authorization problem solving paste
2022-06-24 15:35:00 【PHP Development Engineer 】
Replace this method
public function mpAuth() { list($code, $post_cache_key) = $this->request->params([ ‘code’, ‘cache_key’, ], true); $session_key = Cache::get(‘eb_api_code_’ . post_cache_key); if (!postcachekey);if(!code && !$session_key) return app(‘json’)->fail(‘ privilege grant failed , Wrong parameter ’); miniProgramService = MiniProgramService::create(); if (miniProgramService=MiniProgramService::create();if(code && !$session_key) { try { $userInfoCong = miniProgramService->getUserInfo(miniProgramService−>getUserInfo(code); $session_key = $userInfoCong[‘session_key’]; $cache_key = md5(time() . $code); Cache::set(‘eb_api_code_’ . $cache_key, $session_key, 86400); } catch (Exception $e) { return app(‘json’)->fail(‘ obtain session_key Failure , Please check your configuration !’, [‘line’ => $e->getLine(), ‘message’ => $e->getMessage()]); } }
$data = $this->request->params([
['spread_spid', 0],
['spread_code', ''],
['iv', ''],
['encryptedData', ''],
]);
try {
// Decrypt to get user information
$userInfo = $miniProgramService->encryptor($session_key, $data['iv'], $data['encryptedData']);
} catch (Exception $e) {
if ($e->getCode() == '-41003') return app('json')->fail(' Failed to get session key ', ['line' => $e->getLine(), 'message' => $e->getMessage()]);
throw $e;
}
if (!$userInfo) return app('json')->fail('openid Acquisition failure ');
if (!isset($userInfo['openId'])) $userInfo['openId'] = $userInfoCong['openid'] ?? '';
$userInfo['unionId'] = $userInfoCong['unionid'] ?? $userInfo['unionId'] ?? '';
if (!$userInfo['openId']) return app('json')->fail('openid Acquisition failure ');
/** @var WechatUserRepository $make */
$make = app()->make(WechatUserRepository::class);
$user = $make->syncRoutineUser($userInfo['openId'], $userInfo);
if (!$user)
return app('json')->fail(' privilege grant failed ');
/** @var UserRepository $make */
$userRepository = app()->make(UserRepository::class);
$user[1] = $userRepository->mainUser($user[1]);
$code = intval($data['spread_code']['id'] ?? $data['spread_code']);
// Get whether there is scanning code into the small program
if ($code && ($info = app()->make(RoutineQrcodeRepository::class)->getRoutineQrcodeFindType($code))) {
$data['spread_spid'] = $info['third_id'];
}
$userRepository->bindSpread($user[1], intval($data['spread_spid']));
$tokenInfo = $userRepository->createToken($user[1]);
$userRepository->loginAfter($user[1]);
return app('json')->success($userRepository->returnToken($user[1], $tokenInfo));
}Complete example :http://github.crmeb.net/u/defu
边栏推荐
- Teach you how to deploy the pressure test engine on Tencent cloud
- MySQL toolset: the official export tool mysqlpump
- List of PostgreSQL
- Service visibility and observability
- Brief discussion on the implementation framework of enterprise power Bi CI /cd
- Analysis of dompurify
- Is it safe to open an account for flush stock on mobile phone!
- 动作捕捉系统用于地下隧道移动机器人定位与建图
- 兴业证券靠谱吗?开证券账户安全吗?
- Huangchuping presided over the video conference on fixed-point contact with Zhuhai, resolutely implemented the deployment requirements of the provincial Party committee, and ensured positive results i
猜你喜欢

API data interface for announcement of Hong Kong listed companies

Left hand code, right hand open source, part of the open source road

As a developer, what is the most influential book for you?
Bitmap of redis data structure

动作捕捉系统用于地下隧道移动机器人定位与建图

Two way combination of business and technology to build a bank data security management system

高速公路服务区智能一体机解决方案
Step by step introduction to sqlsugar based development framework (9) -- Realizing field permission control with WinForm control

测试 H5 和小程序的区别,你真的知道吗?

Bert whitening vector dimension reduction and its application
随机推荐
API data interface for announcement of Hong Kong listed companies
leetcode 139. Word break word split (medium)
Who do you want to open a stock account? Is online account opening safe?
Chaos mesh in Tencent -- Tencent mutual entertainment chaotic engineering practice
安防市场进入万亿时代,安防B2B网上商城系统精准对接深化企业发展路径
常见的缺陷管理工具——禅道,从安装到使用手把手教会你
I have been in the industry for 4 years and have changed jobs twice. I have learned a lot about software testing
左手代码,右手开源,开源路上的一份子
07. Tencent cloud IOT device side learning - Data Template
设备通过国标GB28181接入EasyCVR平台,出现断流情况该如何解决?
A brief introduction to the lexical analysis of PostgreSQL
一个简单而功能强大的开发者工具箱Box3.cc
Industry cases of successful digital transformation
Security Analysis on mining trend of dogecoin, a public cloud
同样是初级测试工程师,为啥他薪资高?会这几点面试必定出彩
Service visibility and observability
Istio Troubleshooting: using istio to reserve ports causes pod startup failure
MySQL replication series 6- tables related to replication information
Easynvr has been connected to the third-party supervision platform. How to achieve local Internet access
FPGA based analog I ² C protocol system design (Part 2)