Untitled
Search…
php
1
<?php
2
$filename = realpath( './uploads/20.jpg' );
3
$cfile = new CurlFile( $filename, 'image/jpeg', $filename );
4
$data = array( 'file' => $cfile );
5
6
$taggun_endpoint = 'https://api.taggun.io/api/receipt/v1/simple/file';
7
8
$ch = curl_init();
9
$options = array(
10
CURLOPT_URL => $taggun_endpoint,
11
CURLOPT_RETURNTRANSFER => true,
12
CURLINFO_HEADER_OUT => true,
13
CURLOPT_HEADER => true,
14
CURLOPT_POST => true,
15
CURLOPT_HTTPHEADER => array(
16
'apikey: YOUR API KEY',
17
'Accept: application/json',
18
'Content-Type: multipart/form-data',
19
),
20
CURLOPT_POSTFIELDS => $data,
21
);
22
23
curl_setopt_array( $ch, $options );
24
$result = curl_exec( $ch );
25
$header_info = curl_getinfo( $ch, CURLINFO_HEADER_OUT );
26
$header_size = curl_getinfo( $ch, CURLINFO_HEADER_SIZE );
27
$header = substr( $result, 0, $header_size );
28
$body = substr( $result, $header_size );
29
curl_close( $ch );
30
31
?>
32
33
<!doctype html>
34
<html>
35
<head>
36
<meta charset="utf-8">
37
<title>File Upload results</title>
38
</head>
39
<body>
40
<p>Raw Result: <?php echo $result; ?>
41
<p>Header Sent: <?php echo $header_info; ?></p>
42
<p>Header Received: <?php echo $header; ?></p>
43
<p>Body: <?php echo $body; ?></p>
44
</body>
45
</html>
Copied!
Last modified 6mo ago
Copy link