-
Notifications
You must be signed in to change notification settings - Fork 6
/
list_meetings.js
85 lines (76 loc) · 2.7 KB
/
list_meetings.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/**
* _
* __ _____| |__ _____ __
* \ \ /\ / / _ \ '_ \ / _ \ \/ /
* \ V V / __/ |_) | __/> < @WebexDevs
* \_/\_/ \___|_.__/ \___/_/\_\
*
* READ (list) meetings in Webex with the REST API in Node
* https://developer.webex.com/docs/api/v1/meetings/list-meetings
*
* Step 0: Have a (free) Webex account: https://cart.webex.com/sign-up
* Step 1: Log in to https://developer.webex.com/login
* Step 2: Find your bearer token at
* https://developer.webex.com/docs/getting-started under "Your
* Personal Access Token" in the middle of the page.
* Step 3: Replace the string on the line that defines const myWebexDeveloperToken,
* just below, with your personal bearer (access) token. Hit "save".
* Step 4: Run this file with node (https://nodejs.org/en/download/)
* from within this directory on the command line:
*
* node ./list_meetings.js
*
* Step 5: Profit. Get your app listed in the Webex App Hub!
* https://apphub.webex.com/
*
*/
const https = require('https'); // https://nodejs.org/api/https.html
// You can set your WEBEXTOKEN env to your 12-hour token, OR...
const myWebexDeveloperToken = (typeof process.env.WEBEXTOKEN !=='undefined' )
? process.env.WEBEXTOKEN // Sets the token from your system's ENV if you've done that, OR...
: 'REPLACE ME WITH YOUR WEBEX DEVELOPER PERSONAL ACCESS TOKEN'; // ...replace this text with your 12-hour token
const options = {
method: 'GET',
hostname: 'webexapis.com',
path: '/v1/meetings',
port: 443,
headers: {
Authorization: `Bearer ${myWebexDeveloperToken}`, // Make sure you set your token above!
},
};
const req = https.request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log(
`The title of the first meeting in the list is: ${
JSON.parse(data).items[0].title}`,
);
});
res.on('error', (e) => {
console.error(`Error: ${e.message}`);
});
});
req.end();
/**
* Expected output:
*
*
* The title of the first meeting in the list is: My Meeting Title
*
*
* Where "My Meeting Title" represents the title of the first meeting
* in the list of meetings in your account.
*
* To view all of the fields for the first meeting in the list, simply
* remove the .title from JSON.parse(data).items[0].title above.
*
* To see every single field for every single meeting on your account,
* just strip that further down to: JSON.parse(data)
*
* NOTE: If you do not have meetings in your account, check out the code
* example in ../create/create_meeting.js and run that. Then come
* back here, and you'll have a meeting in your account to retrieve.
*/