这是cURL:
curl -v-数据"data=01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000" https://api.blockchair.com/bitcoin/push/transaction
如何在VB中形成Web请求对象以发布cURL命令的FormEncoded --data?
我尝试过:
Dim strPushAPI As String = "https://api.blockchair.com/bitcoin-cash/push/transaction?"
Dim strTxHex As String = "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000"
Dim bytes As Byte() = Encoding.ASCII.GetBytes(strTxHex)
Dim wrqPush As WebRequest = WebRequest.CreateHttp(strPushAPI)
wrqPush.ContentType = "application/x-www-form-urlencoded"
wrqPush.Method = HttpMethod.Post.Method
Dim kvals = New Dictionary(Of String, String)
kvals.Add("data", strTxHex)
Dim rqsStream As Stream = wrqPush.GetRequestStream
Dim content = New FormUrlEncodedContent(kvals)
content.CopyToAsync(rqsStream)
Dim wrsPush As HttpWebResponse = CType(wrqPush.GetResponse(), HttpWebResponse)
Dim srData As New StreamReader(wrsPush.GetResponseStream)
Dim strResponse As String = srData.ReadToEnd