How to get errors, if SMS sending is failed in REST API using PHP

  • 1
  • Question
  • Updated 1 year ago
  • (Edited)
Hello everyone,

I'm using PHP REST API to send SMS, but unable to send SMS. My request is successful and return SMS ID with all the details but the SMS status is 'SendingFailed', I don't know why?

There is nor error code returned in the response. Please help me to get the errors that why the SMS not sent. 

My request code is as follows:
$url = "https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/sms";
$param=json_encode(array('to'=>array(array('phoneNumber'=>$to)),'from'=>array('phoneNumber'=>'+19164374306'),'text'=>$smsBody));
$response = http($url,'POST',$param,$auth_token);
The response I'm getting is :

Array(
    [uri] => https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/message-...
    [id] => 2788749004
    [to] => Array
        (
            [0] => Array
                (
                    [phoneNumber] => tonumber
                )
        )
    [from] => Array
        (
            [phoneNumber] => +19164374306
            [location] => Sacramento, North, CA
        )
    [type] => SMS
    [creationTime] => 2017-03-18T06:33:39.000Z
    [readStatus] => Read
    [priority] => Normal
    [attachments] => Array
        (
            [0] => Array
                (
                    [id] => 2788749004
                    [uri] => https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/message-...
                    [type] => Text
                    [contentType] => text/plain
                )
        )
    [direction] => Outbound
    [availability] => Alive
    [subject] => Test SMS using a RingCentral Developer account - this  is test msg by vishal
    [messageStatus] => SendingFailed
    [smsSendingAttemptsCount] => 1
    [conversationId] => 2.2628912365145E+18
    [conversation] => Array
        (
            [id] => 2262891236514496402
            [uri] => https://platform.devtest.ringcentral.com/restapi/v1.0/conversation/2262891236514496402
        )
    [lastModifiedTime] => 2017-03-18T06:33:40.041Z
)
Photo of Rakesh Kumar

Rakesh Kumar

  • 50 Points
  • confused

Posted 1 year ago

  • 1
Photo of Benjamin Dean

Benjamin Dean, Alum

  • 8,622 Points 5k badge 2x thumb
Hello Rakesh,

First, I would highly recommend using the official RingCentral PHP SDK if at all possible...why?
  • Simplifies integrations with the RingCentral API
  • Standardizes application development with RingCentral using recommended best practices
  • Open Source SDK === Lots of developers contributing and improving the source (not just you)
  • Since it is one of the official RingCentral SDKs, there are dedicated resources available to help with issues developers report in the Github Issue Tracker
Next, have you checked that the following states of the RingCentral Account/Extension/Phone Numbers can be used to for sending SMS (preferably prior to the SMS API request):
  1. The account has SMS enabled https://developers.ringcentral.com/api-explorer/latest/index.html#/!/Account/loadServiceInfo
  2. The extension has the permission to send SMS: https://developers.ringcentral.com/api-explorer/latest/index.html#/!/Extension/loadExtensionInfo
  3. The "fromNumber" being used in the body of the request is one of the extension's phone numbers that has the "SmsSender" feature listed for that property respectively? https://developers.ringcentral.com/api-explorer/latest/index.html#/!/Extension/listExtensionPhoneNum...
Lastly, it is a recommended best practice to check the authenticated user's Authorization Profile permissions for specific operations prior to executing them: https://developers.ringcentral.com/api-explorer/latest/index.html#/!/Authorization_Profile/loadUserP.... This accomplishes two very important goals:
  1. Allows your application / integration to be proactive about an operation which a user or system is attempting to perform
  2. Improves the user experience by informing a user or service worker of the state which is preventing the desired action (handling more than just the "happy path" of an application's operation)
Full information about these resources is also available in the RingCentral API Reference: https://developers.ringcentral.com/api-docs/latest/index.html
Photo of AK

AK, Official Rep

  • 4,372 Points 4k badge 2x thumb
Hi Rakesh,

Could you please open a support case with devsupport@ringcentral.com and we could take a look at it. 
(Edited)
Photo of AK

AK, Official Rep

  • 4,372 Points 4k badge 2x thumb
You would need to use the Get Extension Info API Endpoint. 

The JSON response would include a field to indicate the features available on the ext :

"serviceFeatures": [    {
      "featureName": "SMS",
      "enabled": true
    },
    {
      "featureName": "SMSReceiving",
      "enabled": true
    },
    {
      "featureName": "Pager",
      "enabled": true
    },
    {
      "featureName": "PagerReceiving",
      "enabled": true
    }
]
Photo of Ryan Ryan

Ryan Ryan

  • 174 Points 100 badge 2x thumb
Thank you for the reply.  What would cause the extension to not have permission to send SMS?  Does every direct phone number we have with RingCentral not have SMS on by default?  Is there a way to validate the setup for the phone number/extension in the main admin portal of RingCentral?
Photo of Ryan Ryan

Ryan Ryan

  • 174 Points 100 badge 2x thumb
Upon calling RingCentral Support (those guys are so awesome and professional by the way), it takes 72 hours for a new phone number to be enabled for SMS.  FYI in case anybody stumbles across this thread and wonders why their SMS is disabled / not working
Photo of AK

AK, Official Rep

  • 4,372 Points 4k badge 2x thumb
Hi Ryan,

Any DL / Direct Number attached to the extension would have the SMS permission ON by default as long as they are of the type
Voice / Fax
The RingCentral Support via Phone would route you to our General Support team and hence probably you would have seen the delay, we BEST recommend our developers to open support cases related to the Developer Platform using one of the below two methods : 
(Edited)
Photo of Ryan Ryan

Ryan Ryan

  • 174 Points 100 badge 2x thumb
I received an error on my production test SMS message and opened a ticket via developer portal.  This was from a phone number that I know works using SMS on the Ringcentral Android app.  Hopefully it can be resolved quickly.

{ "errorCode" : "FeatureNotAvailable", "message" : "Phone number doesn't belong to extension", "errors" : [ { "errorCode" : "MSG-304", "message" : "Phone number doesn't belong to extension" } ] }SMS::::{ "errorCode" : "FeatureNotAvailable", "message" : "Phone number doesn't belong to extension", "errors" : [ { "errorCode" : "MSG-304", "message" : "Phone number doesn't belong to extension" } ] }

If i need to create a new thread, I apologize about hijacking this one but didnt want to lose the trail of my previous questions.
(Edited)