Created
May 12, 2020 17:10
-
-
Save iPokz/0280b4ca482c3a0e503a4b27c6461ff7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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