VB.NET

Imports System
Imports System.Runtime.Remoting.Metadata.W3cXsd2001
Imports System.Security.Cryptography
Imports System.Net

Public Class RFGAPI

    Private Shared apiURL As [String] = "https://api.researchforgood.com/API"
    Private Shared apid As [String] = ""
    Private Shared secretHex As [String] = ""

    Public Shared Sub Main()
        Dim command As [String] = "{ ""command"" : ""test/copy/1"" , ""data1"" : ""THIS IS A TEST""}"
        Dim response As [String] = SendCommand(command)
        Console.WriteLine(response)
    End Sub

    Public Shared Function SendCommand(command As [String]) As [String]
        Dim time As Int32 = (DateTime.UtcNow.Subtract(New DateTime(1970, 1, 1))).TotalSeconds
        Dim hash As [Byte]() = New HMACSHA1(SoapHexBinary.Parse(secretHex).Value).ComputeHash(System.Text.Encoding.UTF8.GetBytes(time & command))
        Dim url As [String] = apiURL & "?apid=" & apid & "&time=" & time & "&hash=" & New SoapHexBinary(hash).ToString()
        Dim client As WebClient = New WebClient()
        Dim response As Byte() = client.UploadData(url, "POST", System.Text.Encoding.UTF8.GetBytes(command))
        Return System.Text.Encoding.UTF8.GetString(response)
    End Function
End Class