Пример #1
0
        echo 'feed: ', $feed['feed'], PHP_EOL;
    }
} else {
    echo 'Error in the feed detection call: ', $response['statusInfo'];
}
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo '############################################', PHP_EOL;
echo '#   Microformats Parsing Example           #', PHP_EOL;
echo '############################################', PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo 'Processing url: ', $demo_url, PHP_EOL;
echo PHP_EOL;
$response = $alchemyapi->microformats('url', $demo_url, null);
if ($response['status'] == 'OK') {
    echo '## Response Object ##', PHP_EOL;
    echo print_r($response);
    echo PHP_EOL;
    echo '## Microformats ##', PHP_EOL;
    foreach ($response['microformats'] as $microformat) {
        echo 'field: ', $microformat['field'], PHP_EOL;
        echo 'data: ', $microformat['data'], PHP_EOL, PHP_EOL;
    }
} else {
    echo 'Error in the microformat parsing call: ', $response['statusInfo'];
}
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
Пример #2
0
$response = $alchemyapi->category('text', $test_text, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->category('html', $test_html, array('url' => 'test'));
assert($response['status'] == 'OK');
$response = $alchemyapi->category('url', $test_url, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->category('random', $test_url, null);
assert($response['status'] == 'ERROR');
//invalid flavor
echo 'Category tests complete!', PHP_EOL, PHP_EOL;
//Feeds
echo 'Checking feeds . . . ', PHP_EOL;
$response = $alchemyapi->feeds('text', $test_text, null);
assert($response['status'] == 'ERROR');
//feeds only works on html and url content
$response = $alchemyapi->feeds('html', $test_html, array('url' => 'test'));
assert($response['status'] == 'OK');
$response = $alchemyapi->feeds('url', $test_url, null);
assert($response['status'] == 'OK');
echo 'Feed tests complete!', PHP_EOL, PHP_EOL;
//Microformats
echo 'Checking microformats . . . ', PHP_EOL;
$response = $alchemyapi->microformats('text', $test_text, null);
assert($response['status'] == 'ERROR');
//microformats only works on html and url content
$response = $alchemyapi->microformats('html', $test_html, array('url' => 'test'));
assert($response['status'] == 'OK');
$response = $alchemyapi->microformats('url', $test_url, null);
assert($response['status'] == 'OK');
echo 'Microformat tests complete!', PHP_EOL, PHP_EOL;
echo '**** All tests are complete! ****', PHP_EOL;