SMS in asp.net web application
how to integrate SMS feature in asp.net web application?
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
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.