I have this code in PHP
<?php
$key = md5('test123'.date("Y-m-d")."3dgdnk5k1yfw3rpy3r5mi25w2zrtmg");
$fields = array(
'apiID' => 'test123',
'date' => date("Y-m-d") ,
'token' => $key,
'collection' => array(
array(
"ID" => 35,
"fecha" => '2013-11-20',
"hora" => '12:15',
"num" => '36646363463636',
"tipo" => 'multa',
"calle" => 'rivadavia',
"altura" => '450',
"dominio" => 'HDP 123'
) ,
array(
"ID" => 36,
"fecha" => '2013-11-20',
"hora" => '12:16' ,
"num" => '36646363463636',
"tipo" => 'hola',
"calle" => 'mitre',
"altura" => '450',
"dominio" => 'HDP 123'
)
)
);
$postFields = http_build_query($fields, 'flags_');
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "http://testpage.com/api");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postFields);
$r = curl_exec($curl);
curl_close($curl);
I need the code equivalent to this request in VB NET or C#
the code that I have done so far in VB NET is this
Imports System.Net
Imports System.IO
Imports System.Xml
Imports System.Text
Imports System.Web
Imports System.Security.Cryptography
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
Dim testString As String = "test1232013-11-223dgdnk5k1yfw3rpy3r5mi25w2zrtmg"
Dim asciiBytes As Byte() = ASCIIEncoding.ASCII.GetBytes(testString)
Dim hashedBytes As Byte() = MD5CryptoServiceProvider.Create().ComputeHash(asciiBytes)
Dim hashedString As String = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower()
Dim post_values As New Dictionary(Of String, String)
post_values.Add("apiID", "test123")
post_values.Add("date", "2013-11-22")
post_values.Add("token", hashedString) ' The hash MD5
'Here i dont know how to publish the array
post_values.Add("collection", "IDacta=35&fecha=2013-11-20&hora=12:15&num=36646363463636&tipo=multa&calle=alberdi&altura=450&dominio=HDP 123")
Dim post_string As String = ""
For Each post_value As KeyValuePair(Of String, String) In post_values
post_string += post_value.Key + "=" + HttpUtility.UrlEncode(post_value.Value) + "&"
Next
post_string = post_string.TrimEnd("&")
Dim vSolicitud As WebRequest = WebRequest.Create("http://testpage.com/api")
vSolicitud.Proxy = Nothing
vSolicitud.Method = "POST"
vSolicitud.ContentType = "application/x-www-form-urlencoded"
Dim vXML As String = post_string
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(vXML)
vSolicitud.ContentLength = byteArray.Length
Dim dataStream As Stream = vSolicitud.GetRequestStream()
dataStream.Write(byteArray, 0, byteArray.Length)
dataStream.Close()
Dim vRespuesta As WebResponse = vSolicitud.GetResponse()
Dim vStream As StreamReader = New StreamReader(vRespuesta.GetResponseStream())
Dim vStr As String = vStream.ReadToEnd().Trim
vRespuesta.Close()
vStream.Close()
TextBox1.Text = vStr
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class
¿ How POST these array values ?
Thanks in advance.