question

Kyle McLaughlin avatar image
Kyle McLaughlin asked Phong Vu edited

SMS Webhook subscription not receiving via PHP and not able to send/receive SMS via devtest GLIP app.

Hello I'm trying to use Webhook subscription for SMS using the code here - https://developers.ringcentral.com/guide/notifications/quick-start/webhook/php I used php sdk installed via composer. I'm using non-gui type of App.

I successfully registered my endpoint that save received data as json file.

{
  "uri": "https://platform.devtest.ringcentral.com/restapi/v1.0/subscription/84810115-4216-400b-a0c4-386ed513abd3",
  "id": "84810115-4216-400b-a0c4-386ed513abd3",
  "creationTime": "2020-04-14T03:56:24.424Z",
  "status": "Active",
  "eventFilters": [
    "/restapi/v1.0/account/275222004/extension/275222004/message-store/instant?type=SMS"
  ],
  "expirationTime": "2020-04-21T03:56:24.424Z",
  "expiresIn": 604799,
  "deliveryMode": {
    "transportType": "WebHook",
    "encryption": false,
    "address": "https://mydomain.com/PodioReWeb/RingCentral/Webhooksms.php?webhookcallback"
  }
}


On my end point this is the code I have.

<?php
require_once $_SERVER['DOCUMENT_ROOT']."/Utilities/Helper/Class.php";
$_POST = json_decode(file_get_contents('php://input'), true); //Catch JSON post request
Helper::LogFile("Logfile_ReceivedData", $_POST, "Data received");
require('vendor/autoload.php');

$RINGCENTRAL_CLIENTID = '<secret>';
$RINGCENTRAL_CLIENTSECRET = '<secret>';
$RINGCENTRAL_SERVER = 'https://platform.devtest.ringcentral.com';
$RINGCENTRAL_USERNAME = '+14704622677';
$RINGCENTRAL_PASSWORD = '<secret>';
$RINGCENTRAL_EXTENSION = '101';

$DELIVERY_ADDRESS = 'https://mydomain.com/PodioReWeb/RingCentral/Webhooksms.php?webhookcallback';

$rcsdk = new RingCentral\SDK\SDK($RINGCENTRAL_CLIENTID, $RINGCENTRAL_CLIENTSECRET, $RINGCENTRAL_SERVER);
$platform = $rcsdk->platform();

if (isset($_REQUEST['webhookcallback'])){
    if (array_key_exists('HTTP_VALIDATION_TOKEN', $_SERVER)) {
        return header("Validation-Token: {$_SERVER['HTTP_VALIDATION_TOKEN']}");
Helper::LogFile("Logfile_ReceivedData", $_POST, "Data received");
    }else{
  Helper::LogFile("Logfile_ReceivedData", $_POST, "Data received");
    }
}else{
    $platform->login($RINGCENTRAL_USERNAME, $RINGCENTRAL_EXTENSION, $RINGCENTRAL_PASSWORD);
    $params = array(
            'eventFilters' => array(
                '/restapi/v1.0/account/~/extension/~/message-store/instant?type=SMS'
                ),
            'deliveryMode' => array(
                'transportType' => "WebHook",
                'address' => $DELIVERY_ADDRESS
            ));
    try {
          $apiResponse = $platform->post('/subscription', $params);
          print_r ("Response: " . $apiResponse->text());
    }catch (Exception $e){
          print_r ("Exception: " . $e->getMessage());
    }
}
?>


The thing is I'm not receiving any webhook notification when I tried to send SMS via Sandbox API (sms sent successfully using sandbox extension). Also I tried sending SMS to the sandbox extension. I do not see the message under GLIP App or not even receiving any Webhook notification for it. When I tried to manually send a message via devtest GLIP app, I received the following error below.

Customer account plan is on Office Premium plan.

subscriptionsapi sms
1586836849472.png (217.8 KiB)
1 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

·
Phong Vu avatar image
Phong Vu answered Phong Vu edited

This filter means your app will receive a notification of incoming text messages sent to a phone number belongs to the extension identified by the extension id "275222004", which I believe is the 101 as you logged in your app with "101".

extension/275222004/message-store/instant?type=SMS"/message-store/instant?type=SMS"

So when you wrote "The thing is I'm not receiving any webhook notification when I tried to send SMS via Sandbox API (sms sent successfully using sandbox extension)", did you send to a phone number owned by the 101 extension?


Let's solve one problem at a time and can you ask the GLIP notification in a new thread (it's a different problem) so it is easier to follow up.

5 comments
1 |1000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Kyle McLaughlin avatar image Kyle McLaughlin commented ·

@Phong Vu thank you for your response. I sent the message using online free tool which this one - http://www.afreesms.com/intl/united-states to this number showing in sandbox credential section 4704622677

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ Kyle McLaughlin commented ·

1/ Not sure why you use that free online service to send SMS. You can easily send a test SMS from your mobile phone to be sure if the SMS can be sent.

2/ I cannot login your sandbox using an admin tool. Not sure why, but can you login and check how many users have you had in that sandbox, have you provision the sandbox main company number to support SMS (assign to operator extension). Or simply add a direct number to the 101 extension to enable SMS.

1 Like 1 ·
Kyle McLaughlin avatar image Kyle McLaughlin Phong Vu ♦♦ commented ·

@Phong Vu I did not use or add a direct number, not sure also how to provision main company number to support SMS. If I add one, will that incur on a billing? I just directly use the sandbox number, but again using send SMS API, I was able to send SMS without any issue using code below.


<?php
require('vendor/autoload.php');
require('includes/config.php');
session_start(
$rcsdk = new RingCentral\SDK\SDK($RINGCENTRAL_CLIENTID, $RINGCENTRAL_CLIENTSECRET, $RINGCENTRAL_SERVER
$platform = $rcsdk->platform();
$platform->login($RINGCENTRAL_USERNAME, $RINGCENTRAL_EXTENSION, $RINGCENTRAL_PASSWORD
$resp = $platform->post('/account/~/extension/~/sms',
    array(
       'from' => array ('phoneNumber' => $RINGCENTRAL_USERNAME),
       'to' => array(array('phoneNumber' => $RECIPIENT)),
       'text' => 'Hello World'
     ));
print_r ($resp->json()->messageStatus);
?>


0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.