欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

ASP.NET(VB)写的后台发送短信实现代码

程序员文章站 2024-03-05 11:19:00
复制代码 代码如下: dim postdata as string dim bytearray as byte() dim objwebrequest as httpweb...
复制代码 代码如下:

dim postdata as string
dim bytearray as byte()
dim objwebrequest as httpwebrequest
dim newstream as stream

postdata = "cell=短信供应商提供信息1&enterpriseid=短信供应商提供信息2&mobile=手机号1,手机号2&message=发送数据测试。。。"
objwebrequest = webrequest.create("http://xxx.yyy.com.cn/smssend.jsp")
objwebrequest.method = "post"
objwebrequest.contenttype = "application/x-www-form-urlencoded"

bytearray = system.text.encoding.utf8.getbytes(postdata)
objwebrequest.contentlength = bytearray.length
newstream = objwebrequest.getrequeststream()
newstream.write(bytearray, 0, bytearray.length)
newstream.close()

'返回数据
dim response as httpwebresponse
dim sr as streamreader
dim textresponse as string
response = objwebrequest.getresponse()
sr = new streamreader(response.getresponsestream(), system.text.encoding.default)
textresponse = sr.readtoend()