CREATE PROCEDURE SendWhatsAppMessage
@AccountSid VARCHAR(50),
@AuthToken VARCHAR(50),
@FromNumber VARCHAR(20),
@ToNumber VARCHAR(20),
@Message VARCHAR(1000)
AS
BEGIN
DECLARE @Url VARCHAR(2000)
DECLARE @PostData VARCHAR(2000)
DECLARE @ResponseText VARCHAR(8000)
DECLARE @WinHttpReq INT

SET @Url = ‘https://api.twilio.com/2010-04-01/Accounts/’ + @AccountSid + ‘/Messages.json’
SET @PostData = ‘From=whatsapp:’ + @FromNumber + ‘&To=whatsapp:’ + @ToNumber + ‘&Body=’ + @Message

EXEC sp_OACreate ‘WinHttp.WinHttpRequest.5.1’, @WinHttpReq OUT;
EXEC sp_OAMethod @WinHttpReq, ‘Open’, NULL, ‘POST’, @Url, ‘false’
EXEC sp_OAMethod @WinHttpReq, ‘SetRequestHeader’, NULL, ‘Content-Type’, ‘application/x-www-form-urlencoded’
EXEC sp_OAMethod @WinHttpReq, ‘SetRequestHeader’, NULL, ‘Authorization’, ‘Basic ‘ + CAST(N” AS XML).value(‘xs:base64Binary(xs:hexBinary(sql:column(“token_bin”)))) AS token
EXEC sp_OAMethod @WinHttpReq, ‘Send’, NULL, @PostData
EXEC sp_OAMethod @WinHttpReq, ‘ResponseText’, @ResponseText OUTPUT

EXEC sp_OADestroy @WinHttpReq;

SELECT @ResponseText
END

  • Stockholm shoppers can use their smartphones or tablets to shop […]

    Continue reading
  • Food delivery apps have grown in popularity in recent years […]

    Continue reading
  • Connecting your mobile app to the backend servers, databases, and […]

    Continue reading
  • Stockholm shoppers can use their smartphones or tablets to shop […]

    Continue reading
  • Food delivery apps have grown in popularity in recent years […]

    Continue reading

Leave A Comment