本文整理汇总了PHP中Wechat::authorizeUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Wechat::authorizeUser方法的具体用法?PHP Wechat::authorizeUser怎么用?PHP Wechat::authorizeUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Wechat
的用法示例。
在下文中一共展示了Wechat::authorizeUser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if (\Helper::hasSessionCachedUser()) {
// //如果请求中含有code,需要重定向至不带code的页面.
// if (\Wechat::urlHasAuthParameters($request->fullUrl())) {
// return redirect(\Wechat::urlRemoveAuthParameters($request->fullUrl()));
// }
return $next($request);
}
$user = \Wechat::authorizeUser($request->url());
/*
* if auth failed, this user maybe not a subscribed account,
* but we allow this man go on to education page.
* */
if ($user) {
\Session::put(AppConstant::SESSION_USER_KEY, $user->all());
} else {
\Session::put(AppConstant::SESSION_USER_KEY, null);
}
return $next($request);
}
示例2: webShopIndex
public function webShopIndex(Request $request)
{
if ($request->has('cooperator_id')) {
\Session::put('cooperator_id', $request->input('cooperator_id'));
}
if (!\Helper::hasSessionCachedUser()) {
$user = \Wechat::authorizeUser($request->fullUrl());
if ($user) {
\Session::put(AppConstant::SESSION_USER_KEY, $user->all());
} else {
\Session::put(AppConstant::SESSION_USER_KEY, null);
}
}
$user = \Helper::getSessionCachedUser();
$customer = \Helper::getCustomerOrNull();
if (!$customer) {
$customer = Customer::create(['openid' => $user['openid'], 'referrer_id' => 0, 'type_id' => 1]);
$customer->update(['cooperator_id' => $request->input('cooperator_id', null)]);
return redirect('http://web.ohmate.cn/redirect/shop-index?customer_id=' . $customer->id . '&first_in=1');
}
return redirect('http://web.ohmate.cn/redirect/shop-index?customer_id=' . $customer->id);
}