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; echo PHP_EOL; echo PHP_EOL; echo 'Processing url: ', $demo_url, PHP_EOL; echo PHP_EOL; $response = $alchemyapi->feeds('url', $demo_url, null); if ($response['status'] == 'OK') { echo '## Response Object ##', PHP_EOL; echo print_r($response); echo PHP_EOL; echo '## Feeds ##', PHP_EOL; foreach ($response['feeds'] as $feed) { echo 'feed: ', $feed['feed'], PHP_EOL; } } else { echo 'Error in the feed detection call: ', $response['statusInfo']; } echo PHP_EOL; echo PHP_EOL;
echo 'Relations tests complete!', PHP_EOL, PHP_EOL; //Category echo 'Checking category . . . ', PHP_EOL; $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);