File Example
;
$apiKey = '';
$file = '';
$url = 'https://api.slipok.com/api/line/apikey/' . $branchId;
$headers = [
'Content-Type: multipart/form-data',
'x-authorization: ' . $apiKey
];
$fields = [
'files' => new CURLFile($file),
'log' => true,
// 'amount' => amount, // Add this to check with amount of the slip
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $fields,
CURLOPT_HTTPHEADER => $headers,
));
$response = curl_exec($curl);
curl_close($curl);
if($response){
$json_response = json_decode($response);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if($http_code === 200 && $json_response->{'success'} === true) {
// Handle correct slip
echo(json_encode($json_response->{'data'})); // Slip data
} else {
// Handle incorrect slip
echo 'code: '.$json_response->{'code'}; // Error code
echo '
';
echo 'message: '.$json_response->{'message'}; // Error message
}
} else {
echo curl_errno($curl); // Curl error no
echo curl_error($curl); // Curl error message
}
Data Example
;
$apiKey = '';
$data = '';
$url = 'https://api.slipok.com/api/line/apikey/' . $branchId;
$headers = [
'Content-Type: multipart/form-data',
'x-authorization: ' . $apiKey
];
$fields = [
'data' => $data,
'log' => true,
// 'amount' => amount, // Add this to check with amount of the slip
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $fields,
CURLOPT_HTTPHEADER => $headers,
));
$response = curl_exec($curl);
curl_close($curl);
if($response){
$json_response = json_decode($response);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if($http_code === 200 && $json_response->{'success'} === true) {
// Handle correct slip
echo(json_encode($json_response->{'data'})); // Slip data
} else {
// Handle incorrect slip
echo 'code: '.$json_response->{'code'}; // Error code
echo '
';
echo 'message: '.$json_response->{'message'}; // Error message
}
} else {
echo curl_errno($curl); // Curl error no
echo curl_error($curl); // Curl error message
}
Url Example
;
$apiKey = '';
$imageUrl = '';
$url = 'https://api.slipok.com/api/line/apikey/' . $branchId;
$headers = [
'Content-Type: multipart/form-data',
'x-authorization: ' . $apiKey
];
$fields = [
'url' => $imageUrl,
'log' => true,
// 'amount' => amount, // Add this to check with amount of the slip
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $fields,
CURLOPT_HTTPHEADER => $headers,
));
$response = curl_exec($curl);
curl_close($curl);
if($response){
$json_response = json_decode($response);
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if($http_code === 200 && $json_response->{'success'} === true) {
// Handle correct slip
echo(json_encode($json_response->{'data'})); // Slip data
} else {
// Handle incorrect slip
echo 'code: '.$json_response->{'code'}; // Error code
echo '
';
echo 'message: '.$json_response->{'message'}; // Error message
}
} else {
echo curl_errno($curl); // Curl error no
echo curl_error($curl); // Curl error message
}