本文整理匯總了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);
}