File tree Expand file tree Collapse file tree 2 files changed +17
-11
lines changed Expand file tree Collapse file tree 2 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -49,14 +49,22 @@ if (!isset($_GET['code'])) {
49
49
50
50
// Get resource owner
51
51
try {
52
- $resourceOwner = $amazon ->getResourceOwner($accessToken);
52
+ $resourceOwner = $amazonProvider ->getResourceOwner($accessToken);
53
53
} catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
54
54
exit($e->getMessage());
55
55
}
56
56
57
57
// Now you can store the results to session etc.
58
58
$_SESSION['accessToken'] = $accessToken;
59
59
$_SESSION['resourceOwner'] = $resourceOwner;
60
+
61
+ var_dump(
62
+ $resourceOwner->getId(),
63
+ $resourceOwner->getName(),
64
+ $resourceOwner->getPostalCode(),
65
+ $resourceOwner->getEmail(),
66
+ $resourceOwner->toArray()
67
+ );
60
68
}
61
69
```
62
70
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public function __construct(array $response = array())
33
33
*/
34
34
public function getId ()
35
35
{
36
- return $ this ->getValueByKey ($ this ->response , 'data.0.id ' );
36
+ return $ this ->getValueByKey ($ this ->response , 'user_id ' );
37
37
}
38
38
39
39
/**
@@ -43,29 +43,27 @@ public function getId()
43
43
*/
44
44
public function getName ()
45
45
{
46
- $ firstName = $ this ->getValueByKey ($ this ->response , 'data.0.firstName ' ) ?: '' ;
47
- $ lastName = $ this ->getValueByKey ($ this ->response , 'data.0.lastName ' ) ?: '' ;
48
- return $ firstName . ($ firstName && $ lastName ? ' ' : '' ) . $ lastName ;
46
+ return $ this ->getValueByKey ($ this ->response , 'name ' );
49
47
}
50
48
51
49
/**
52
- * Get resource owner username
50
+ * Get resource owner postal code
53
51
*
54
52
* @return string|null
55
53
*/
56
- public function getUsername ()
54
+ public function getPostalCode ()
57
55
{
58
- return null ;
56
+ return $ this -> getValueByKey ( $ this -> response , ' postal_code ' ) ;
59
57
}
60
58
61
59
/**
62
- * Get resource owner location
60
+ * Get resource owner email
63
61
*
64
62
* @return string|null
65
63
*/
66
- public function getLocation ()
64
+ public function getEmail ()
67
65
{
68
- return null ;
66
+ return $ this -> getValueByKey ( $ this -> response , ' email ' ) ;
69
67
}
70
68
71
69
/**
You can’t perform that action at this time.
0 commit comments