question

yash15167 avatar image
yash15167 asked Phong Vu answered

how to integrate SMS feature in asp.net web application?

SMS in asp.net web application

getting started
1 |3000

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
Add the RingCentral.Net Nuget package to your app.

See the example code below:

CS Code:

using System;
using System.Web;
using System.Web.UI;
using System.Threading.Tasks;
using RingCentral;
using System.Web.UI.WebControls;
namespace RingCentral_SMS
{
    public partial class Default : System.Web.UI.Page
    {
        RestClient rc = null;
        const string RINGCENTRAL_CLIENTID = "Your_App_Client_Id";
        const string RINGCENTRAL_CLIENTSECRET = "Your_App_Client_Secret";         const string RINGCENTRAL_USERNAME = "Your_Username";         const string RINGCENTRAL_PASSWORD = "Your_Password";         const string RINGCENTRAL_EXTENSION = "ExtensionNumber";         protected void sendMessageButton_Clicked(object sender, EventArgs e)         {             LoginRingCentralAsync().Wait();         }         private async Task LoginRingCentralAsync()         {             if (rc == null)             {                 rc = new RestClient(RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, false);                 await rc.Authorize(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD);                 if (rc.token.access_token.Length > 0)                 {                     result.InnerHtml = "Authorized";                     SendMessageAsync().Wait();                 }                 else                 {                     result.InnerHtml = "Unauthorized";                 }             }         }         private async Task SendMessageAsync()         {             var parameters = new CreateSMSMessage();             parameters.from = new MessageStoreCallerInfoRequest { phoneNumber = sendFrom.Value };             parameters.to = new MessageStoreCallerInfoRequest[] { new MessageStoreCallerInfoRequest { phoneNumber = sendTo.Value } };             parameters.text = subject.Value;             var resp = await rc.Restapi().Account().Extension().Sms().Post(parameters);             result.InnerHtml = resp.messageStatus;         }     } }
HTML CODE:

<%@ Page Language="C#" Inherits="RingCentral_SMS.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>RingCentral Connect Platform Demo</title>
</head>
<body>
    <h2>RingCentral APIs Demo</h2>
    <form id="form2" method="post" enctype="multipart/form-data" runat="server">
        <div>
            <h3>Messaging Demo</h3>
            <span>From</span>
            <input type="text" id="sendFrom" name="text" size="20" runat="server"/> <br/>
            <span>To</span>
            <input type="text" id="sendTo" name="text" size="20" runat="server"/> <br/>
            <span>Text message</span>
            <input type="text" id="subject" name="text" size="100" runat="server"/> <br/>
            <asp:Button ID="Button2" Text="Send" runat="server" onClick="sendMessageButton_Clicked"/>
        </div>
    </form>
    <br/>
    <div>Result:</div>
    <div id="result" runat="server" />
</body>
</html> 

Hope this helps!
+ Phong
1 |3000

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

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys