Hi Team
I want to send text.I try this code for sending sms:
<?php
require('vendor/autoload.php');
use RingCentral\SDK\SDK;
// Parse the .env file
$dotenv = new Dotenv\Dotenv(getcwd());
$dotenv->load();
try {
// Create SDK instance
$rcsdk = new SDK($_ENV['GLIP_APPKEY'], $_ENV['GLIP_APPSECRET'] , $_ENV['GLIP_SERVER'], 'Demo', '1.0.0');
// Create Platform instance
$platform = $rcsdk->platform();
/*
* Using the caching mechanism
*/
$cacheDir = __DIR__ . DIRECTORY_SEPARATOR . '_cache';
$file = $cacheDir . DIRECTORY_SEPARATOR . 'platform.json';
$cachedAuth = array();
if (file_exists($file)) {
$cachedAuth = json_decode(file_get_contents($file), true);
}
$platform->auth()->setData($cachedAuth);
// To login user
$rc=$platform->login($_ENV['username'],$_ENV['extension'],$_ENV['password']);
$apiResponse = $rcsdk->platform()->post('/account/~/extension/~/sms', array(
'from' => array('phoneNumber' => 'your-ringcentral-sms-number'),
'to' => array(
array('phoneNumber' => 'mobile-number'),
),
'text' => 'Test from PHP',
));
/*
* Setup 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 now." . PHP_EOL;
} catch (Exception $e) {
print 'Webhook Setup Error: ' . $e->getMessage() . PHP_EOL;
}
after running this code I get this error:
Please tell me if i miss something in this.Also suggest docs for sending msg from local machine.
I have added the functionality to send sms in the webhook.php file as below:
$botman->hears('send sms to {number}', function (BotMan $bot, $query) {
$bot->reply($query);
})->driver(GlipBotman::class);
So the Adapter listens to the message and parses the {number} and sends SMS. Kindly try the updated branch and provide us your feedback:
https://github.com/ringcentral/glip-botman/tree/bot-provisioner
Please note the changes in the .env file below:
https://github.com/ringcentral/glip-botman/tree/bot-provisioner#configure-your-bot
If there is any concern, please feel free to open issue in the Github Repository below:
https://github.com/ringcentral/glip-botman/issues
Hope this information helps!
I want more help. Can you please help to resolve?
I am successfully registered my bot.Now I want to add API in that like (SMS,Meeting,Call,).
- I try first SMS API as above mention which I won't be able to implement in my local machine file.
- I try this same from UI in that when I run post and get method for SMS then it's working.
- Can you please tell me how to add this code in my local machine code(php).
- Where we can see the send msg?
- I search every where but i won't be able to find right option to see my send message in my inbox ?
Also, please note that if your application is of the type " Server/Bot" you cannot authorize using the Password Flow
Since your app was authorized using the OAuth2.0, the adapter stores the token in a folder named _cache which you could re-use to make API calls.
Make sure to delete the below line inside index.php and re-try:
$rc=$platform->login($_ENV['username'],$_ENV['extension'],$_ENV['password']);
I cannot say much w/o seeing some of the code though.
+ Phong
However, we have a demo in our Official PHP SDK to send SMS. Kindly go on and read below to know more:
API Documentation:
https://developer.ringcentral.com/api-docs/latest/index.html#!#RefSMSMessages.html
SMS Demo:
https://github.com/ringcentral/ringcentral-php#send-sms---make-post-request
Hope this helps!
A new Community is coming to RingCentral!
Posts are currently read-only as we transition into our new platform.We thank you for your patience
during this downtime.
Try Workflow Builder
Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!Try RingCentral Workflow Builder