<?php // Load the AlchemyAPI module code. include "../module/AlchemyAPI.php"; // Or load the AlchemyAPI PHP+CURL module. /*include "../module/AlchemyAPI_CURL.php";*/ // Create an AlchemyAPI object. $alchemyObj = new AlchemyAPI(); // Load the API key from disk. $alchemyObj->loadAPIKey("api_key.txt"); // Extract RSS / ATOM feed links from a web URL. $result = $alchemyObj->URLGetFeedLinks("http://www.techcrunch.com/"); echo "{$result}<br/><br/>\n"; // Load a HTML document to analyze. $htmlFile = file_get_contents("data/example.html"); // Extract RSS / ATOM feed links from a HTML document. $result = $alchemyObj->HTMLGetFeedLinks($htmlFile, "http://www.test.com/"); echo "{$result}<br/><br/>\n";
function CheckParameterTypes() { $alchemyObj = new AlchemyAPI(); $alchemyObj->loadAPIKey("api_key.txt"); $htmlFile = file_get_contents("../example/data/example.html"); $htmlFile2 = file_get_contents("../example/data/example2.html"); $htmlFile2_nolinks = file_get_contents("../example/data/example2_nolinks.html"); $namedEntityParams = new AlchemyAPI_NamedEntityParams(); $keywordParams = new AlchemyAPI_KeywordParams(); try { $result = $alchemyObj->URLGetRankedNamedEntities("http://www.cnn.com/2010/HEALTH/06/03/gulf.fishermans.wife/index.html?hpt=C2", "xml", $keywordParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->HTMLGetRankedNamedEntities($htmlFile2, "http://www.test.com/", "xml", $keywordParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->TextGetRankedNamedEntities("Hello my name is Bob. I am speaking to you at this very moment. Are you listening to me, Bob?", "xml", $keywordParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->URLGetCategory("http://www.techcrunch.com/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->TextGetCategory("Latest on the War in Iraq.", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->HTMLGetCategory($htmlFile, "http://www.test.com/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->URLGetConstraintQuery("http://microformats.org/wiki/hcard", "1st link", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->HTMLGetConstraintQuery($htmlFile, "http://www.test.com/", "1st link", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->URLGetFeedLinks("http://www.techcrunch.com/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->HTMLGetFeedLinks($htmlFile, "http://www.test.com/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->URLGetRankedKeywords("http://www.techcrunch.com/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->TextGetRankedKeywords("Hello my name is Bob Jones. I am speaking to you at this very moment. Are you listening to me, Bob?", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->HTMLGetRankedKeywords($htmlFile, "http://www.test.com/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->URLGetLanguage("http://www.techcrunch.fr/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->TextGetLanguage("Hello my name is Bob Jones. I am speaking to you at this very moment. Are you listening to me, Bob?", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->HTMLGetLanguage($htmlFile, "http://www.test.com/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->URLGetMicroformats("http://microformats.org/wiki/hcard", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->HTMLGetMicroformats($htmlFile, "http://www.test.com/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->URLGetTitle("http://www.techcrunch.com/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->URLGetText("http://www.techcrunch.com/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->URLGetRawText("http://www.techcrunch.com/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->HTMLGetTitle($htmlFile, "http://www.test.com/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->HTMLGetText($htmlFile, "http://www.test.com/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } try { $result = $alchemyObj->HTMLGetRawText($htmlFile, "http://www.test.com/", "xml", $namedEntityParams); //should throw an exception for mismatched parameters assert(1 == 0); } catch (Exception $e) { } }