使用Api / read api返回值

时间:2013-04-29 13:10:04

标签: vb.net api sms

我正在使用SMS提供商的api。

Dim url As String
url = "http://weburl.jsp?usr=abc&pass=def&msisdn=95786123384645&sid=ABC&msg=welcome&mt=0"
webbrowser1.navigate(url)

我从提供商处获得的网址。有没有其他更好的方法使用api发送短信?

还有平衡的api,它会返回平衡。现在我想把这个平衡放在标签上。怎么做?

http://weburl/CreditCheck.jsp?usr=abc&pass=def  

在浏览器上复制粘贴显示余额,但我希望它在标签中。

我正在使用vb.net 2008 windows app,

提前致谢。

1 个答案:

答案 0 :(得分:0)

您可以使用HttpWebRequest和HttpWebResponse,就像这样......

Dim sUrl As String = "http://weburl/CreditCheck.jsp?usr=abc&pass=def"

Dim wRequest As HttpWebRequest = DirectCast(System.Net.HttpWebRequest.Create(sUrl), HttpWebRequest)

wRequest.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials 'Not always needed
wRequest.Method = "GET"

Dim wResponse As HttpWebResponse = DirectCast(wRequest.GetResponse(), HttpWebResponse)

Dim sResponse As String = ""

Using srRead As New StreamReader(wResponse.GetResponseStream())
    sResponse = srRead.ReadToEnd()
End Using

然后,您需要解析结果以提取余额