当前位置:网站首页>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
边栏推荐
- Data stack technology sharing: how to use data stack for data collection?
- Openinstall joins hands with the book chain to help channel data analysis and create the era of Book Networking
- Restoring to an earlier version in CVS
- Service visibility and observability
- Is it safe to open an account for stock speculation in the top ten securities app rankings in China
- Teach you how to view version information with mongodb
- 东方财富哪个开户更安全,更好点
- When installing Wireshark, npcap cannot be installed successfully. It is recommended to use WinPcap first
- [bitbear story collection] June MVP hero story | technology practice collision realm thinking
- Bitmap of redis data structure
猜你喜欢
![[bitbear story collection] June MVP hero story | technology practice collision realm thinking](/img/b7/ca2f8cfb124e7c68da0293624911d1.png)
[bitbear story collection] June MVP hero story | technology practice collision realm thinking

熬夜整理出的软件测试【高频】面试题大全(2022最新)

Mots clés pour la cartographie es; Ajouter une requête par mot - clé à la requête term; Changer le type de mot - clé de cartographie

【我的OpenGL学习进阶之旅】OpenGL的坐标系的学习笔记

Method after charging the idea plug-in material theme UI

From pair to unordered_ Map, theory +leetcode topic practice

设备通过国标GB28181接入EasyCVR平台,出现断流情况该如何解决?

Wide measuring range of jishili electrometer

leetcode. 12 --- integer to Roman numeral

Laravel8 uses faker to call factory to fill data
随机推荐
Monitoring and warning | is the website attacked?
US Senate promotes bipartisan gun safety bill
How to optimize performance
Istio practical skill: enable accesslog locally
Teach you how to view version information with mongodb
Actual combat | a tortuous fishing counteraction
Design of vga/lcd display controller system based on FPGA (Part 2)
API data interface for announcement of Hong Kong listed companies
证券账户理财安全吗??
Stm32f1 and stm32cubeide programming examples -ws2812b full color LED driver (based on spi+dma)
golang中Map的并发写入
[log service CLS] a taste of Tencent cloud log service CLS
How to achieve long-term development of voice social source code?
Step by step introduction to sqlsugar based development framework (9) -- Realizing field permission control with WinForm control
A series of problems caused by IPVS connection reuse in kubernetes
update+catroot+c000021a+critical service failed+drivers+intelide+viaide+000000f
Do you really know the difference between H5 and applet?
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
安装wireshark时npcap怎么都安装不成功,建议先用winpcap
大智慧开户要选什么证券公司比较好,更安全一点