API – PHP cURL source code
// USERNAME
$username = 'YOUR USERNAME';
// PASSWORD
$password = 'YOUR PASSWORD';
// URL
$url = 'https://api.idpack.cloud/producer/';
// SET ARRAY
$data = array();
// USER SECRET KEY
$data += ["user_secret_key" => 'YOUR USER SECRET KEY'];
// PROJECT SECRET KEY
$data += ["project_secret_key" => 'YOUR PROJECT SECRET KEY'];
// SET API CALL
$data += ["API_Action" => 'GET_record'];
// GET THIS PRIMARY KEY
$data += ["API_Search" => ["idc_id_number", '10000']];
// RETURN OUTPUT FORMAT (JSON, XML)
$data += ["API_OutputFormat" => 'json'];
// API Version
$data += ["API_Version" => 1];
// CONVERT ARRAY TO JSON
$data_string = json_encode($data);
// INIT CURL
$ch = curl_init();
if ($ch === false) {
echo 'failed to initialize';
} else {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 2000);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_URL, $url);
$headers = array(
'Accept-Language:en-US',
'Accept:application/json',
'Content-Type:application/json',
'Content-Length:'.strlen($data_string));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
// EXECUTE API CALL
$content = curl_exec($ch);
if ($content === false) {
echo curl_error($ch).' '.curl_errno($ch);
} else {
$httpReturnCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpReturnCode <> 200) {
echo 'HTTP return code not 200. (Code '.$httpReturnCode.')';
} else {
echo $content;
}
}
}