Beispiel #1
0
<?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 concept tags from a web URL.
$result = $alchemyObj->URLGetRankedConcepts("http://www.techcrunch.com/");
echo "{$result}<br/><br/>\n";
// Extract concept tags from a text string.
$result = $alchemyObj->TextGetRankedConcepts("This thing has a steering wheel, tires, and an engine.  Do you know what it is?");
echo "{$result}<br/><br/>\n";
// Load a HTML document to analyze.
$htmlFile = file_get_contents("data/example.html");
// Extract concept tags from a HTML document.
$result = $alchemyObj->HTMLGetRankedConcepts($htmlFile, "http://www.test.com/");
echo "{$result}<br/><br/>\n";
Beispiel #2
0
function CheckNoParams()
{
    $alchemyObj = new AlchemyAPI();
    $alchemyObj->loadAPIKey("api_key.txt");
    $htmlFile = file_get_contents("../example/data/example.html");
    $htmlFile2 = file_get_contents("../example/data/example2.html");
    // Extract a ranked list of named entities from a web URL.
    $result = $alchemyObj->URLGetRankedNamedEntities("http://www.techcrunch.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->TextGetRankedNamedEntities("Hello my name is Bob.  I am speaking to you at this very moment.  Are you listening to me, Bob?");
    CheckForOKStatus($result);
    $result = $alchemyObj->HTMLGetRankedNamedEntities($htmlFile, "http://www.test.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->URLGetCategory("http://www.techcrunch.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->TextGetCategory("Latest on the War in Iraq.");
    CheckForOKStatus($result);
    $result = $alchemyObj->HTMLGetCategory($htmlFile, "http://www.test.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->URLGetConstraintQuery("http://microformats.org/wiki/hcard", "1st link");
    CheckForOKStatus($result);
    $result = $alchemyObj->HTMLGetConstraintQuery($htmlFile, "http://www.test.com/", "1st link");
    CheckForOKStatus($result);
    $result = $alchemyObj->URLGetFeedLinks("http://www.techcrunch.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->HTMLGetFeedLinks($htmlFile, "http://www.test.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->URLGetRankedKeywords("http://www.techcrunch.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->TextGetRankedKeywords("Hello my name is Bob Jones.  I am speaking to you at this very moment.  Are you listening to me, Bob?");
    CheckForOKStatus($result);
    $result = $alchemyObj->HTMLGetRankedKeywords($htmlFile, "http://www.test.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->URLGetRankedConcepts("http://www.techcrunch.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->TextGetRankedConcepts("Hello my name is Bob Jones.  I am speaking to you at this very moment.  Are you listening to me, Bob?");
    CheckForOKStatus($result);
    $result = $alchemyObj->HTMLGetRankedConcepts($htmlFile, "http://www.test.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->URLGetLanguage("http://www.techcrunch.fr/");
    CheckForOKStatus($result);
    $result = $alchemyObj->TextGetLanguage("Hello my name is Bob Jones.  I am speaking to you at this very moment.  Are you listening to me, Bob?");
    CheckForOKStatus($result);
    $result = $alchemyObj->HTMLGetLanguage($htmlFile, "http://www.test.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->URLGetMicroformats("http://microformats.org/wiki/hcard");
    CheckForOKStatus($result);
    $result = $alchemyObj->HTMLGetMicroformats($htmlFile, "http://www.test.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->URLGetTitle("http://www.techcrunch.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->URLGetText("http://www.techcrunch.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->URLGetRawText("http://www.techcrunch.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->HTMLGetTitle($htmlFile, "http://www.test.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->HTMLGetText($htmlFile, "http://www.test.com/");
    CheckForOKStatus($result);
    $result = $alchemyObj->HTMLGetRawText($htmlFile, "http://www.test.com/");
    CheckForOKStatus($result);
}