Links used in using curl for Clarifai

php code, to find out what is in an image:

$random_string=substr(str_shuffle(MD5(microtime())), 0, 5);

echo ‘<h1>’.$random_string.'</h1>’;

$imgurl=”http://perisic.com/four/train/img.php?s=”.$random_string.”&t=2.jpg”;

$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_VERBOSE, ‘1’);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch, CURLOPT_URL, “https://api.clarifai.com/v2/models/aaa03c23b3724a16a56b629203edc62c/outputs”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // curl_exec returns the value

$headers = array(
‘Content-Type: application/json’,
“Authorization: xyzabcd”
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$fields = ‘{“inputs”:[{“data”:{“image”:{“url”:”‘.$imgurl.'”}}}]}’; // Your image here.
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);

// grab URL and pass it to the browser
$result = curl_exec($ch);

// echo ‘<h2>’.$result.'</h2>’;

$mydata= json_decode($result, true);

$concepts = $mydata[“outputs”][0][“data”][“concepts”];

// var_dump($concepts);

$conceptlist=””;
for($i=0;$i < sizeof($concepts); $i++ ) {
if($i != 0 ) { $conceptlist .= ‘, ‘; }
$value = $concepts[$i];
$conceptlist .= $value[“name”];
}

echo “<h3>Concepts: “;
echo $conceptlist;
echo “</h3>”;

// close cURL resource, and free up system resources
curl_close($ch);

echo ‘<img src=”‘.$imgurl.'” alt=”‘.$conceptlist.'” title=”‘.$conceptlist.'”>’;

Finally: C:\Users\vim\curl\curl.exe –verbose –libcurl tmp1.c -H “Authorization: Key xyzabcd” -H “Content-Type: application/json” –data “{“”inputs””:[{“”data””:{“”image””:{“”url””:””http://www.perisic.com/five/imgfive.php?s=helbo&w=10″”}}}]}”  https://api.clarifai.com/v2/models/aaa03c23b3724a16a56b629203edc62c/outputs

(You must replace xyzabcd with your own API key)