-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
42 lines (26 loc) · 1.02 KB
/
index.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
<?php
require('vendor/autoload.php');
use RingCentral\SDK\SDK;
// Parse the .env file
$dotenv = new Dotenv\Dotenv(getcwd());
$dotenv->load();
try {
// Create a Subscription using webhooks method
$rcsdk = new SDK($_ENV['GLIP_APPKEY'], $_ENV['GLIP_APPSECRET'] , $_ENV['GLIP_SERVER'], 'Demo', '1.0.0');
$platform = $rcsdk->platform();
$auth = $platform->login($_ENV['GLIP_USERNAME'], $_ENV['GLIP_EXTENSION'], $_ENV['GLIP_PASSWORD']);
// Setup the Webhook Subscription
$apiResponse = $platform->post('/subscription',array(
"eventFilters"=>array(
"/restapi/v1.0/glip/groups",
"/restapi/v1.0/glip/posts"
),
"deliveryMode"=>array(
"transportType"=> "WebHook",
"address"=>$_ENV['GLIP_WEBHOOK_URL']
)
));
print PHP_EOL . "Wohooo, your Bot is Registered. Please follow the instructions on on-boarding the bot into Glip" . PHP_EOL;
} catch (Exception $e) {
print 'Webhook Setup Error: ' . $e->getMessage() . PHP_EOL;
}