Skip to content

Instantly share code, notes, and snippets.

@iPokz
Created May 12, 2020 17:10
Show Gist options
  • Select an option

  • Save iPokz/0280b4ca482c3a0e503a4b27c6461ff7 to your computer and use it in GitHub Desktop.

Select an option

Save iPokz/0280b4ca482c3a0e503a4b27c6461ff7 to your computer and use it in GitHub Desktop.
<?php
$curl = curl_init();
$file = '35721.jpg';
$data = [
'file' => new CURLFile($file, mime_content_type($file), basename($file)),
];
curl_setopt_array($curl,
[
CURLOPT_URL => 'http://api-thai-id.iapp.co.th/idocr/detect/front',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $data,
]
);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
header('Content-type:application/json;charset=utf-8');
$json = json_decode($response); // Object
$json = json_decode($response, true); // Array
echo $response;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment