예제 #1
0
} else {
    echo 'Error in the microformat parsing call: ', $response['statusInfo'];
}
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo '############################################', PHP_EOL;
echo '#   Image Extraction Example               #', PHP_EOL;
echo '############################################', PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo 'Processing url: ', $demo_url, PHP_EOL;
echo PHP_EOL;
$response = $alchemyapi->imageExtraction('url', $demo_url, null);
if ($response['status'] == 'OK') {
    echo '## Response Object ##', PHP_EOL;
    echo print_r($response);
    echo PHP_EOL;
    echo '## Image ##', PHP_EOL;
    echo 'Image: ', $response['image'], PHP_EOL;
} else {
    echo 'Error in the image extraction call: ', $response['statusInfo'];
}
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo '############################################', PHP_EOL;
예제 #2
0
파일: tests.php 프로젝트: fstream9/Slash
$imageFile = fopen($imageName, "r") or die("Unable to open file!");
$imageData = fread($imageFile, filesize($imageName));
fclose($imageFile);
//image keywords
echo 'Checking image keywords . . . ', PHP_EOL;
$response = $alchemyapi->image_keywords('url', $test_url, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->image_keywords('image', $imageData, array('imagePostMode' => 'raw'));
assert($response['status'] == 'OK');
$response = $alchemyapi->image_keywords('random', $test_url, null);
assert($response['status'] == 'ERROR');
//invalid flavor
echo 'Image keyword tests complete!', PHP_EOL, PHP_EOL;
//image extraction
echo 'Checking image extraction . . . ', PHP_EOL;
$response = $alchemyapi->imageExtraction('url', $test_url, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->imageExtraction('random', $test_url, null);
assert($response['status'] == 'ERROR');
//invalid flavor
echo 'Image extraction tests complete!', PHP_EOL, PHP_EOL;
//taxonomy
echo 'Checking Taxonomy . . . ', PHP_EOL;
$response = $alchemyapi->taxonomy('text', $test_text, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->taxonomy('random', $test_text, null);
assert($response['status'] == 'ERROR');
//invalid flavor
echo 'Taxonomy tests complete!', PHP_EOL, PHP_EOL;
//combined
echo 'Checking Combined . . . ', PHP_EOL;