Click here to Skip to main content
15,887,294 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hello

i have SMS.aspx.vb source code file and with devexpress components and i need to integrate it with a new Bulk SMS provider using HTTP API through one of these methods :
1 - using HTTP JSON POST
2 - using HTTP GET
3 - using SOAP

can any one help me write the code to integrate it in my asp.net vb web form ( web application )
Posted
Updated 26-Mar-15 7:04am
v2

You can use WebClient to call the api

https://msdn.microsoft.com/en-us/library/system.net.webclient(v=vs.110).aspx[^]

If you google for examples of using webclient to call api with json you should find a lot of examples.
 
Share this answer
 
Comments
Member 11558177 26-Mar-15 18:50pm    
need more help

i saw this code :
Public Function SendAnSMSMessage(message As String) As Boolean
Dim request As HttpWebRequest = DirectCast(WebRequest.Create("http://api.pennysms.com/jsonrpc"), HttpWebRequest)
request.Method = "POST"
request.ContentType = "application/json"

Dim json As String = "{
"Username": "",
"Password": "",
"Tagname": "",
"RecepientNumber": "05xxxxxx;05xxxxxx",
"VariableList": "",
"ReplacementList": "",
"Message": "test",
"SendDateTime": 0,
"EnableDR": False
}

streamWriter.Write(json)
End Using
Dim httpResponse = DirectCast(httpWebRequest.GetResponse(), HttpWebResponse)
Using streamReader = New StreamReader(httpResponse.GetResponseStream())
Dim responseText = streamReader.ReadToEnd()
'Now you have your response.
'or false depending on information in the response
Return True
End Using
End Function

Return True
End Function



???
This code can be used to send SMS from VB.Net using HTTP requests:

C#
Imports System
Imports System.IO
Imports System.Net
Imports System.Text
Imports System.Web

Public Class fMain

 Private Sub bSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bSend.Click
        Dim request As HttpWebRequest
        Dim response As HttpWebResponse = Nothing
        Dim url As String
        Dim username As String
        Dim password As String
        Dim host As String
        Dim originator As String

        Try

            host = "http://127.0.0.1:9501"
            originator = "06201234567"
            username = "admin"
            password = "abc123"

            url = host + "/api?action=sendmessage&" _
                     & "username=" & HttpUtility.UrlEncode(username) _
                     & "&password=" + HttpUtility.UrlEncode(password) _
                     & "&recipient=" + HttpUtility.UrlEncode(tbReceiver.Text) _
                     & "&messagetype=SMS:TEXT" _
                     & "&messagedata=" + HttpUtility.UrlEncode(tbMessage.Text) _
                     & "&originator=" + HttpUtility.UrlEncode(originator) _
                     & "&serviceprovider=GSMModem1" _
                     & "&responseformat=html"

            request = DirectCast(WebRequest.Create(url), HttpWebRequest)

            response = DirectCast(request.GetResponse(), HttpWebResponse)

            MessageBox.Show("Response: " & response.StatusDescription)

        Catch ex As Exception
        End Try
    End Sub
End Class


(Reference: VB.NET HTTP sms example guide[^])
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900