-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtrack-status.php
More file actions
45 lines (37 loc) · 1.36 KB
/
track-status.php
File metadata and controls
45 lines (37 loc) · 1.36 KB
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
<?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();
$platform->login( getenv('RINGCENTRAL_USERNAME'),
getenv('RINGCENTRAL_EXTENSION'),
getenv('RINGCENTRAL_PASSWORD') );
function check_status( $messageId ) {
global $platform;
$r = $platform->get("/account/~/extension/~/message-store/{$messageId}" );
return $r->json()->messageStatus;
}
$r = $platform->post('/account/~/extension/~/sms', array(
'from' => array('phoneNumber' => getenv('RINGCENTRAL_USERNAME')),
'to' => array(
array('phoneNumber' => getenv('RINGCENTRAL_RECEIVER')),
),
'text' => 'Message content',
));
$messageId = $r->json()->id;
print_r("Message ID: " . $messageId . "\n");
$status = check_status( $messageId );
if ($status == "Delivered") {
print_r('Message was sent successfully');
} else if ($status == "Queued") {
print_r("Message is queued. Will check again in 5 seconds...\n");
sleep(5);
print_r("New status is " . check_status($messageId) . "\n");
} else {
print_r("Status is " . $status . "\n");
}
?>