diff --git a/网页授权.md b/网页授权.md index ded6506..aa7f722 100644 --- a/网页授权.md +++ b/网页授权.md @@ -23,4 +23,19 @@ $wechat->auth->user(); ``` +## 示例: + +```php +// 如果已经授权 +if ($wechat->auth->authorized()) { + $user = $wechat->auth->user();// 获取已经登录后用户信息 + Session::set('logged_open_id', $user['open_id']); + + return Redirect::to(你的授权后的页面); +} else { + $to = 微信授权完成后跳回你的地址,就是当前代码所在的 URL; + $wechat->auth->redirect($to, $state = 'STATE', $scope = 'snsapi_base'); +} +``` + 更多关于微信网页授权 API 请参考: http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html \ No newline at end of file