Skip to content

Instantly share code, notes, and snippets.

@spdin
Last active October 16, 2019 18:58
Show Gist options
  • Select an option

  • Save spdin/bdd4228b71c6af2c9abb7503e20300c7 to your computer and use it in GitHub Desktop.

Select an option

Save spdin/bdd4228b71c6af2c9abb7503e20300c7 to your computer and use it in GitHub Desktop.
API end point request using PHP
<?php
include 'config.php';
use GuzzleHttp\Client;
require 'vendor/autoload.php';
$client = new Client();
$ip_api = 'http://35.202.12.206:8811/kk-json';
$myfile = fopen('kartukeluarga.jpg','rb');
$res = $client->post($ip_api,
['multipart' => [
[
'name' => 'image',
'contents' => $myfile,
'filename' => 'data.jpg'
],
]
]);
$array = json_decode($res->getBody(), true);
echo '<pre>'; print_r($array['output']); echo '</pre>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment