inital commit
This commit is contained in:
61
webroot/Staff/rc-sms.php
Normal file
61
webroot/Staff/rc-sms.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This is a script which sends SMS to provided numbers from RingCentral Account
|
||||
* using RingCentral SDK PHP Client
|
||||
*
|
||||
* @author Azhar Uddin <getazharuddin@gmail.com>
|
||||
*/
|
||||
|
||||
require('vendor/autoload.php');
|
||||
use RingCentral\SDK\SDK;
|
||||
// Create SDK instance
|
||||
$credentials = array(
|
||||
'account_phone' => '+12055120205', // your RingCentral account phone number
|
||||
'extension' => 101, // or number
|
||||
'password' => 'NewFunnel100##',
|
||||
'clientId' => 'km7h2pAvSaS0M2WIE2ugAA',
|
||||
'clientSecret' => 'tKgTpqKsRwmN8k5MBxixAA9V1c_rZbSnqf064Ol22l1A',
|
||||
'server' => 'https://platform.devtest.ringcentral.com', // for production - https://platform.ringcentral.com
|
||||
'smsNumber' => '+12055120205', // any of SMS-enabled numbers on your RingCentral account
|
||||
'mobileNumber' => '+12012673412', // receiver of this SMS
|
||||
'dateFrom' => 'yyyy-mm-dd', // dateFrom
|
||||
'dateTo' => 'yyyy-mm-dd', // dateT
|
||||
'smsText' => 'This is a Test SMS from RTG'
|
||||
);
|
||||
$rcsdk = new SDK($credentials['clientId'], $credentials['clientSecret'], $credentials['server'], 'Fax|SMS|MMS', '1.0.0');
|
||||
$platform = $rcsdk->platform();
|
||||
|
||||
try {
|
||||
// Authorize
|
||||
$platform->login($credentials['account_phone'], $credentials['extension'], $credentials['password']);
|
||||
// Find SMS-enabled phone number that belongs to extension
|
||||
//$phoneNumbers = $platform->get('/account/~/extension/~/phone-number', array('perPage' => 'max'))->json()->records;
|
||||
$smsNumber = $credentials['smsNumber'];
|
||||
// $smsNumber = null;
|
||||
// foreach ($phoneNumbers as $phoneNumber) {
|
||||
// if (in_array('SmsSender', $phoneNumber->features)) {
|
||||
// $smsNumber = $phoneNumber->phoneNumber;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// print 'SMS Phone Number: ' . $smsNumber . PHP_EOL;
|
||||
// Send SMS
|
||||
|
||||
if ($smsNumber) {
|
||||
$response = $platform
|
||||
->post('/account/~/extension/~/sms', array(
|
||||
'from' => array('phoneNumber' => $smsNumber),
|
||||
'to' => array(
|
||||
array('phoneNumber' => $credentials['mobileNumber']),
|
||||
),
|
||||
'text' => $credentials['smsText'],
|
||||
));
|
||||
print 'Sent SMS ' . $response->json()->uri . PHP_EOL;
|
||||
} else {
|
||||
print 'SMS cannot be sent: no SMS-enabled phone number found...' . PHP_EOL;
|
||||
}
|
||||
}catch( \Exception $e) {
|
||||
// echo 'error';
|
||||
echo $e->getMessage();
|
||||
}
|
||||
Reference in New Issue
Block a user