Exemplo n.º 1
0
    echo 'iso-639-1: ', $response['iso-639-1'], PHP_EOL;
    echo 'native speakers: ', $response['native-speakers'], PHP_EOL;
} else {
    echo 'Error in the language detection call: ', $response['statusInfo'];
}
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo '############################################', PHP_EOL;
echo '#   Author 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->author('url', $demo_url, null);
if ($response['status'] == 'OK') {
    echo '## Response Object ##', PHP_EOL;
    echo print_r($response);
    echo PHP_EOL;
    echo '## Author ##', PHP_EOL;
    echo 'author: ', $response['author'], PHP_EOL;
} else {
    echo 'Error in the author extraction call: ', $response['statusInfo'];
}
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo '############################################', PHP_EOL;
echo '#   Feed Dection Example                   #', PHP_EOL;
echo '############################################', PHP_EOL;
Exemplo n.º 2
0
$response = $alchemyapi->text('url', $test_url, null);
assert($response['status'] == 'OK');
echo 'Clean text tests complete!', PHP_EOL, PHP_EOL;
//Text Raw
echo 'Checking raw text . . . ', PHP_EOL;
$response = $alchemyapi->text_raw('text', $test_text, null);
assert($response['status'] == 'ERROR');
//text_raw only works on html and url content
$response = $alchemyapi->text_raw('html', $test_html, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->text_raw('url', $test_url, null);
assert($response['status'] == 'OK');
echo 'Raw text tests complete!', PHP_EOL, PHP_EOL;
//Author
echo 'Checking author . . . ', PHP_EOL;
$response = $alchemyapi->author('text', $test_text, null);
assert($response['status'] == 'ERROR');
//author only works on html and url content
$response = $alchemyapi->author('html', $test_html, null);
assert($response['status'] == 'ERROR');
//there is no author listed in the test HTML content
$response = $alchemyapi->author('url', $test_url, null);
assert($response['status'] == 'OK');
echo 'Author tests complete!', PHP_EOL, PHP_EOL;
//Language
echo 'Checking language . . . ', PHP_EOL;
$response = $alchemyapi->language('text', $test_text, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->language('html', $test_html, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->language('url', $test_url, null);