| Conditions | 3 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 46 | public function getUserFacebook($accessToken) |
||
| 47 | { |
||
| 48 | $fb = new Facebook\Facebook([ |
||
| 49 | 'app_id' => $this->appId, |
||
| 50 | 'app_secret' => $this->appSecret, |
||
| 51 | 'default_graph_version' => $this->graphVersion, |
||
| 52 | ]); |
||
| 53 | $fb->setDefaultAccessToken($accessToken); |
||
| 54 | |||
| 55 | try { |
||
| 56 | $response = $fb->get('/me?fields=id,email,first_name,last_name'); |
||
| 57 | $this->userNode = $response->getGraphUser(); |
||
| 58 | |||
| 59 | return $this->userNode; |
||
| 60 | } catch (Facebook\Exceptions\FacebookResponseException $e) { |
||
| 61 | // When Graph returns an error |
||
| 62 | throw new \Exception('Graph returned an error: '.$e->getMessage()); |
||
| 63 | } catch (Facebook\Exceptions\FacebookSDKException $e) { |
||
| 64 | // When validation fails or other local issues |
||
| 65 | throw new \Exception('Facebook SDK returned an error: '.$e->getMessage()); |
||
| 66 | } |
||
| 67 | } |
||
| 68 | } |
||
| 69 |