Skip to main content
Question

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

  • April 14, 2020
  • 1 reply
  • 722 views

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 RingCentralSDKSDK($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.

1 reply

PhongVu
Community Manager
Forum|alt.badge.img
  • Community Manager
  • April 14, 2020

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.