Beispiel #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 '#   Title 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->title('url', $demo_url, null);
if ($response['status'] == 'OK') {
    echo '## Response Object ##', PHP_EOL;
    echo print_r($response);
    echo PHP_EOL;
    echo '## Title ##', PHP_EOL;
    echo 'title: ', $response['title'], PHP_EOL;
} else {
    echo 'Error in the title extraction call: ', $response['statusInfo'];
}
echo PHP_EOL;
echo PHP_EOL;
echo PHP_EOL;
echo '############################################', PHP_EOL;
echo '#   Relation Extraction Example            #', PHP_EOL;
echo '############################################', PHP_EOL;
Beispiel #2
0
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);
assert($response['status'] == 'OK');
$response = $alchemyapi->language('random', $test_url, null);
assert($response['status'] == 'ERROR');
//invalid flavor
echo 'Language tests complete!', PHP_EOL, PHP_EOL;
//Title
echo 'Checking title . . . ', PHP_EOL;
$response = $alchemyapi->title('text', $test_text, null);
assert($response['status'] == 'ERROR');
//title only works on html and url content
$response = $alchemyapi->title('html', $test_html, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->title('url', $test_url, null);
assert($response['status'] == 'OK');
echo 'Title tests complete!', PHP_EOL, PHP_EOL;
//Relations
echo 'Checking relations . . . ', PHP_EOL;
$response = $alchemyapi->relations('text', $test_text, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->relations('html', $test_html, null);
assert($response['status'] == 'OK');
$response = $alchemyapi->relations('url', $test_url, null);
assert($response['status'] == 'OK');