电子合同API开发文档 v1

图片合并pdf

请求地址:/v1/MergeImages2Pdf.json

请求方式:POST

接口版本: v1

接口描述:

Imports System.Text
Imports System.IO
Imports System.Net
Imports System.Web
Class APIStore

    'HTTP的Post请求方式(推荐)
    'strUrl 请求地址
    'param 请求数据
    Public Function APIStorePost(strUrl As String, param As String) As String
        Dim httpWebRequest As HttpWebRequest = TryCast(WebRequest.Create(strUrl), HttpWebRequest)
        httpWebRequest.Method = "POST"      '指定允许数据发送的请求的一个协议方法
        httpWebRequest.ContentType = "application/x-www-form-urlencoded"        '设置 ContentType 属性设置为适当的值
        Dim data As Byte() = Encoding.UTF8.GetBytes(param)
        Using stream As Stream = httpWebRequest.GetRequestStream()            '写入数据
            stream.Write(data, 0, data.Length)
        End Using
        Dim webResponse As WebResponse = TryCast(httpWebRequest.GetResponse(), HttpWebResponse)        '发起请求,得到返回对象
        Dim dataStream As Stream = webResponse.GetResponseStream()
        Dim reader As New StreamReader(dataStream, Encoding.UTF8)
        Dim returnStr As String = reader.ReadToEnd()
        ' Clean up the streams and the response.
        reader.Close()
        webResponse.Close()
        Return returnStr
    End Function


    'HTTP的Get请求方式
    'strUrl 请求地址
    'param 请求数据
    Public Function APIStoreGet(strUrl As String, param As String) As String
        Dim httpWebRequest As HttpWebRequest = TryCast(WebRequest.Create(Convert.ToString(strUrl & Convert.ToString("?")) & param), HttpWebRequest)
        httpWebRequest.Method = "GET"        '指定允许数据发送的请求的一个协议方法
        httpWebRequest.ContentType = "application/x-www-form-urlencoded"        '设置 ContentType 属性设置为适当的值
        Dim webResponse As WebResponse = TryCast(httpWebRequest.GetResponse(), HttpWebResponse)        '发起请求,得到返回对象
        Dim dataStream As Stream = webResponse.GetResponseStream()
        Dim reader As New StreamReader(dataStream, Encoding.UTF8)
        Dim returnStr As String = reader.ReadToEnd()
        ' Clean up the streams and the response.
        reader.Close()
        webResponse.Close()
        Return returnStr
    End Function

    '获取内容
    '@param type 请求方式,POST,GET,推荐POST
    Public Sub getBalance(type As String)
        Dim url As String="https://api-v2.1dq.com/v1/MergeImages2Pdf.json"
        Dim params As String=""
        Dim returnStr As String = Nothing
        If type.Equals("GET") Then
            returnStr = Convert.ToString("get result:") & Me.APIStoreGet(url, param)
        Else
            returnStr = Convert.ToString("post result:") & Me.APIStorePost(url, param)
        End If
        Console.WriteLine(returnStr)
    End Sub
End Class