Skip to content

Instantly share code, notes, and snippets.

@ytakky2014
Created November 28, 2016 10:56
Show Gist options
  • Save ytakky2014/d2220aa767391f0955771f908b260952 to your computer and use it in GitHub Desktop.
Save ytakky2014/d2220aa767391f0955771f908b260952 to your computer and use it in GitHub Desktop.
Use Docomo Image API Sample
<?php
$file = file_get_contents($image_path);
$ch = curl_init();
curl_setopt_array($ch,[
CURLOPT_URL => $api_url . '?APIKEY=' . $api_key,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => [
'modelName' => 'food',
'image' => new CURLFile($image_path)
],
]);
$exec = curl_exec($ch);
$results = json_decode($exec);
$results = $results->candidates;
foreach ($results as $result) {
$tag = $result->tag;
$score = $result->score;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment