majiameng /
OAuth2
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Oauth 登录事例 |
||
| 4 | */ |
||
| 5 | @header('Content-Type: text/html; charset=UTF-8'); |
||
|
0 ignored issues
–
show
|
|||
| 6 | // 引用vendor |
||
| 7 | require __DIR__.'/../../vendor/autoload.php'; |
||
| 8 | require '../oauth2.php'; |
||
| 9 | |||
| 10 | //引入配置文件 |
||
| 11 | $params = require('../config/params.php'); |
||
| 12 | |||
| 13 | try{ |
||
| 14 | $name="qq";//登录类型,例:qq / google |
||
| 15 | $oauth = new oauth2($params); |
||
| 16 | if (empty($_GET['code'])) { |
||
| 17 | /** 登录 */ |
||
| 18 | $result = $oauth->login($name); |
||
| 19 | // var_dump($result['url']);die; |
||
| 20 | //重定向到第三方登录页 |
||
| 21 | header('Location: ' . $result['url']); |
||
| 22 | }else{ |
||
| 23 | /** 登录回调 */ |
||
| 24 | $result = $this->callback($name); |
||
| 25 | var_dump($result);die; |
||
| 26 | } |
||
| 27 | }catch(Exception $e){ |
||
| 28 | echo 'Oauth登录失败!'.$e->getMessage(); |
||
| 29 | } |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.