1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
liveid.php
См. документацию.
1<?php
2
3namespace Bitrix\Mail\Helper\OAuth;
4
5use Bitrix\Main;
6use Bitrix\Mail;
7
9{
10
11 protected function __construct()
12 {
13 $this->oauthEntity = new LiveIdInterface;
14
15 $this->oauthEntity->addScope(array(
16 'wl.emails',
17 'wl.imap',
18 'wl.offline_access',
19 ));
20 }
21
22 protected function check()
23 {
24 $provider = new \CSocServLiveIdOAuth;
25
26 return $provider->checkSettings();
27 }
28
29 protected function mapUserData(array $userData)
30 {
31 return array(
32 'email' => $userData['emails']['account'],
33 'first_name' => $userData['first_name'],
34 'last_name' => $userData['last_name'],
35 'full_name' => $userData['name'],
36 'image' => sprintf('https://apis.live.net/v5.0/%s/picture?type=small', $userData['id']),
37 'error' => $userData['error']['message'],
38 );
39 }
40
41 public static function getServiceName()
42 {
43 return 'liveid';
44 }
45
46 public function getControllerUrl()
47 {
48 return \CSocServLiveIdOAuth::CONTROLLER_URL;
49 }
50
51}
52
53if (Main\Loader::includeModule('socialservices'))
54{
55 class_exists('CSocServLiveIdOAuth');
56
57 class LiveIdInterface extends \CLiveIdOAuthInterface
58 {
59
60 public function setCode($code)
61 {
62 $this->code = $code;
63 }
64
65 public function setToken($access_token)
66 {
67 $this->access_token = $access_token;
68 }
69
70 public function getStorageTokens()
71 {
72 return false;
73 }
74
75 public function getTokenData()
76 {
77 return array(
78 'access_token' => $this->access_token,
79 'refresh_token' => $this->refresh_token,
80 'expires_in' => Mail\Helper\OAuth::convertTokenExpiresToUnixtimeIfNeed($this->accessTokenExpires),
81 );
82 }
83
84 public function getCurrentUser()
85 {
86 if (empty($this->access_token))
87 {
88 return false;
89 }
90
91 $httpClient = new \Bitrix\Main\Web\HttpClient();
92 $httpClient->setHeader('Authorization', 'Bearer ' . $this->access_token);
93
94 $result = $httpClient->get(static::CONTACTS_URL);
95
96 if (!empty($result))
97 {
98 try
99 {
100 $result = \Bitrix\Main\Web\Json::decode($result);
101 }
102 catch (\Exception $e)
103 {
104 $result = null;
105 }
106 }
107
108 if (is_array($result))
109 {
110 $result = array_merge(
111 $result,
112 $this->getTokenData()
113 );
114 }
115
116 return $result;
117 }
118
119 public function setAccessTokenExpires($expires): void
120 {
121 $this->accessTokenExpires = (int)$expires;
122 }
123
124 }
125}
if(!Loader::includeModule('messageservice')) $provider
Определения callback_ednaruimhpx.php:21
static getServiceName()
Определения liveid.php:41
mapUserData(array $userData)
Определения liveid.php:29
getControllerUrl()
Определения liveid.php:46
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$result
Определения get_property_values.php:14
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
Определения options.php:195