This page presents two examples, one on PHP and the other in JAVA, for properly making the call.
http://customer.ogangi.com/mmc/rest/api/createBroadcastFromJson/8/-1/434/peter/true/testJsonBroadcast/null/d1F2T3Y4N56/signature
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; import java.net.URL; import javax.crypto.Mac; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; public static void main(String[] args) { String base = "http://customer.ogangi.com/mmc/rest/api/"; String method = "createBroadcastFromJson/"; String params = "8/-1/434/peter/true/testJsonBroadcast/null"; String keypublic = "d1F2T3Y4N56"; String keyprivate = "A1B2T3J4N5"; String signature = signHmacSHA256(params, keyprivate.getBytes()); System.out.println(call(base + method + params + "/" + keypublic + "/" + signature, "POST")); } public static String call(String sUrl, String method) { System.out.println(sUrl); String outputXml = ""; try { URL url = new URL(sUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setDoOutput(true); conn.setUseCaches(false); conn.setRequestProperty( "Content-Type", "application/json" ); conn.setRequestProperty("Accept", "application/json"); conn.setRequestMethod(method); OutputStream os = conn.getOutputStream(); OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8"); osw.write("[{\"mobilenumber\":\"00000000\",\"text\":\"Test1 createBroadcastFromJson\"}," + "{\"mobilenumber\":\"00000000\"," + "\"text\":\"Test2 createBroadcastFromJson\"}]"); osw.flush(); osw.close(); BufferedReader d = new BufferedReader(new InputStreamReader( conn.getInputStream())); String line = ""; while ((line = d.readLine()) != null) { outputXml += line; } d.close(); conn.disconnect(); return outputXml; } catch (Exception e) { e.printStackTrace(); return null; } } private static String signHmacSHA256(String message, byte[] key) { try { SecretKey signingKey = new SecretKeySpec(key, "HMACSHA256"); Mac mac = Mac.getInstance("HMACSHA256"); mac.init(signingKey); byte[] digest = mac.doFinal(message.getBytes("UTF-8")); char[] hexadecimals = new char[digest.length * 2]; for (int i = 0; i < digest.length; ++i) { for (int j = 0; j < 2; ++j) { int value = (digest[i] >> (4 - 4 * j)) & 0xf; char base = (value < 10) ? ('0') : ('a' - 10); hexadecimals[i * 2 + j] = (char) (base + value); } } return new String(hexadecimals); } catch (Exception e) { e.printStackTrace(); return message; } }
<?php $data = '[{"mobilenumber":"00000000","text":"Test1 createBroadcastFromJson"},{"mobilenumber":"00000000","text":"Test2 createBroadcastFromJson"}]'; $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,"http://customer.ogangi.com/mmc/rest/api/createBroadcastFromJson/8/-1/434/peter/true/testJsonBroadcast/null/d1F2T3Y4N56/signature"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS,$data); $result = curl_exec ($ch); echo $result; ?>