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>’;


$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, “”);
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);

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

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””:””″”}}}]}”

(You must replace xyzabcd with your own API key)