C#.NET
using System;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using System.Security.Cryptography;
using System.Net;
public class RFGAPI
{
private static String apiURL = "https://sandbox.saysoforgood.com/API";
private static String apid = ""; // put your api id here
private static String secretHex = ""; // put your secret here
public static void Main()
{
String command = "{ \"command\" : \"test/copy/1\" , \"data1\" : \"THIS IS A TEST\"}";
String response = SendCommand(command);
Console.WriteLine(response);
}
public static String SendCommand(String command)
{
Int32 time = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
Byte[] hash = new HMACSHA1(SoapHexBinary.Parse(secretHex).Value).ComputeHash(System.Text.Encoding.UTF8.GetBytes(time + command));
String url = apiURL + "?apid="+apid+"&time="+time+"&hash="+new SoapHexBinary(hash).ToString();
WebClient client = new WebClient();
byte[] response = client.UploadData(url,"POST",System.Text.Encoding.UTF8.GetBytes(command));
return System.Text.Encoding.UTF8.GetString(response);
}
}