-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsend-sms.php
30 lines (25 loc) · 1.03 KB
/
send-sms.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
<?php
use Symfony\Component\Dotenv\Dotenv;
require('vendor/autoload.php');
$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/.env');
$rcsdk = new RingCentral\SDK\SDK(getenv('RINGCENTRAL_CLIENT_ID'),
getenv('RINGCENTRAL_CLIENT_SECRET'),
getenv('RINGCENTRAL_SERVER_URL'));
$platform = $rcsdk->platform();
try {
$platform->login( getenv('RINGCENTRAL_USERNAME'),
getenv('RINGCENTRAL_EXTENSION'),
getenv('RINGCENTRAL_PASSWORD'));
$params = array(
'from' => array('phoneNumber' => getenv('RINGCENTRAL_USERNAME')),
'to' => array(
array('phoneNumber' => getenv('RECIPIENT_PHONE_NUMBER')),
),
'text' => 'This is a test message from PHP.',
);
$r = $platform->post('/account/~/extension/~/sms', $params);
print("Message sent. Message delivery status: " . $r->json()->messageStatus . "\n");
}catch (\RingCentral\SDK\Http\ApiException $e) {
print 'Expected HTTP Error: ' . $e->getMessage() . PHP_EOL;
}