Skip to content

Instantly share code, notes, and snippets.

@germanattanasio
Created March 27, 2016 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save germanattanasio/ca22c0d47755d6f023f1 to your computer and use it in GitHub Desktop.
Save germanattanasio/ca22c0d47755d6f023f1 to your computer and use it in GitHub Desktop.
Example of classifying an image using Visual Recognition in PHP
<?php
$data = ;
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_POST => true,
CURLOPT_URL => "https://gateway.watsonplatform.net/visual-recognition-beta/api/v2/classify?version=2015-12-02",
CURLOPT_USERPWD => "USERNAME:PASSWORD",
CURLOPT_POSTFIELDS => array("images_file" => "@/path/to/your/image.png"),
CURLOPT_RETURNTRANSFER => true
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
@200GAUTAM
Copy link

Thanks for the script . was really helpful for the hackathon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment