HTTP API集成 [英] HTTP API integration

查看:91
本文介绍了HTTP API集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



i有SMS.aspx.vb源代码文件和devexpress组件,我需要通过一个使用HTTP API将它与一个新的批量SMS提供程序集成这些方法:

1 - 使用HTTP JSON POST

2 - 使用HTTP GET

3 - 使用SOAP



可以帮助我编写代码以将其集成到我的asp.net vb web表单(web应用程序)中

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 )

推荐答案

你可以使用WebClient来调用api



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



如果你谷歌上使用webclient用json调用api的例子你应该找到很多例子。
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.


这段代码可以用的o使用HTTP请求从VB.Net发送短信:



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

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





(参考: VB.NET HTTP sms示例指南 [ ^ ])


这篇关于HTTP API集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆