how to integrate SMS feature in asp.net web application?
Tags: getting started
Mar 29, 2019 at 10:48am • 1 replies • 0 likes
yash
SMS in asp.net web application
1 Answer
Add the
RingCentral.Net Nuget package to your app.
See the example code below:
CS Code:
Hope this helps!
+ Phong
See the example code below:
CS Code:
using System;HTML CODE:
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; } } }
<%@ 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
0
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