forked from cosmocode/dokuwiki-plugin-oauthfacebook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.php
48 lines (38 loc) · 971 Bytes
/
action.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
use OAuth\OAuth2\Service\Facebook;
/**
* Service Implementation for oAuth Facebook authentication
*/
class action_plugin_oauthfacebook extends \dokuwiki\plugin\oauth\Adapter
{
/** * @inheritDoc */
public function getUser()
{
$oauth = $this->getOAuthService();
$data = array();
$result = json_decode($oauth->request('/me?fields=name,email'), true);
if (!empty($result['username'])) {
$data['user'] = $result['username'];
} else {
$data['user'] = $result['name'];
}
$data['name'] = $result['name'];
$data['mail'] = $result['email'];
return $data;
}
/** @inheritDoc */
public function getScopes()
{
return [Facebook::SCOPE_EMAIL];
}
/** @inheritDoc */
public function getLabel()
{
return 'Facebook';
}
/** @inheritDoc */
public function getColor()
{
return '#3b5998';
}
}