-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcallback.php
43 lines (32 loc) · 1.27 KB
/
callback.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
<?php
//error_reporting(E_ALL);
//ini_set('display_errors', 'on');
require_once 'config.php';
$plugin = ZoomApiPlugin::create();
$zoomPluginEnabled = $plugin->get('tool_enable');
$zoomPluginClientId = $plugin->get('clientid');
$zoomPluginClientSecret = $plugin->get('clientsecret');
$zoomPluginRedirectUri = api_get_path(WEB_PLUGIN_PATH).'zoomapi/callback.php';
//print_r($zoomPluginClientId);
//define('CLIENT_ID', $zoomPluginClientId);
//define('CLIENT_SECRET', $zoomPluginClientSecret);
//define('REDIRECT_URI', $zoomPluginRedirectUri);
try {
$client = new GuzzleHttp\Client(['base_uri' => 'https://zoom.us']);
$response = $client->request('POST', '/oauth/token', [
"headers" => [
"Authorization" => "Basic ". base64_encode($zoomPluginClientId.':'.$zoomPluginClientSecret)
],
'form_params' => [
"grant_type" => "authorization_code",
"code" => $_GET['code'],
"redirect_uri" => $zoomPluginRedirectUri
],
]);
$token = json_decode($response->getBody()->getContents(), true);
$db = new ZoomApi();
$update = $db->update_access_token(json_encode($token));
echo $update;
} catch(Exception $e) {
echo $e->getMessage();
}