If you are using encoded data with a hash, you can update the hash key this way
POST: https://coberapi.com/api/1.0/updateHash
secret | "secret": "eeeniemeenieminiemooooo" |
$data = ['secret' => 'eeeniemeenieminiemooooo'];
$ch = curl_init('https://coberapi.com/api/1.0/updateHash');
curl_setopt($ch, CURLOPT_USERPWD, 'demoapi' . ":" . 'CorrectHorseBatteryStaple');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($ch);
curl_close($ch);
const https = require('https');
const data = {
secret: 'eeeniemeenieminiemooooo'
};
const options = {
hostname: 'coberapi.com',
path: '/api/1.0/updateHash',
method: 'POST',
auth: 'demoapi:CorrectHorseBatteryStaple',
headers: {
'Content-Type': 'application/json'
}
};
const req = https.request(options, (res) => {
let responseData = '';
res.on('data', (chunk) => {
responseData += chunk;
});
res.on('end', () => {
console.log(responseData);
});
});
req.write(JSON.stringify(data));
req.end();
using System;
using System.IO;
using System.Net;
using System.Text;
class Program
{
static void Main()
{
string url = "https://coberapi.com/api/1.0/updateHash";
string username = "demoapi";
string password = "CorrectHorseBatteryStaple";
string data = "{\"secret\":\"eeeniemeenieminiemooooo\"}";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/json";
request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(Encoding.UTF8.GetBytes(username + ":" + password)));
using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
{
writer.Write(data);
}
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream responseStream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(responseStream))
{
string responseData = reader.ReadToEnd();
Console.WriteLine(responseData);
}
}
}
import java.io.IOException;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.charset.StandardCharsets;
public class Main {
public static void main(String[] args) throws IOException {
String url = "https://coberapi.com/api/1.0/updateHash";
String username = "demoapi";
String password = "CorrectHorseBatteryStaple";
String data = "{\"secret\":\"eeeniemeenieminiemooooo\"}";
URL urlObject = new URL(url);
HttpURLConnection connection = (HttpURLConnection) urlObject.openConnection();
connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Authorization", "Basic " + java.util.Base64.getEncoder().encodeToString((username + ":" + password).getBytes(StandardCharsets.UTF_8)));
try (OutputStream os = connection.getOutputStream()) {
byte[] input = data.getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
} else {
System.out.println("HTTP request failed with response code: " + responseCode);
}
}
}