xpath("//entity"); $resultArr = array(); foreach ($entities as $key => $value) { $typeArr = $doc->xpath("/results/entities/entity[$key]/type"); $textArr = $doc->xpath("/results/entities/entity[$key]/text"); if (count($typeArr) > 0 && count($textArr) > 0 && strlen($typeArr[0]) > 0) { $type = "$typeArr[0]"; $text = "$textArr[0]"; $disambArr = $doc->xpath("/results/entities/entity[$key]/disambiguated/name"); if (count($disambArr) > 0 && strlen($disambArr[0]) > 0) { $doDisamb = get_option('alchemyapi-disamb-enabled'); if (strlen($doDisamb) < 1) { $doDisamb = "true"; } if ($doDisamb == "true") { $text = "$disambArr[0]"; } } if (!array_key_exists($type, $resultArr)) { $resultArr[$type] = array(); } if (!in_array($text, $resultArr[$type])) { $resultArr[$type][] = $text; } } } return $resultArr; } function AlchemyAPI_CheckAPIKey() { $apiKey = get_option('alchemyapi-key'); if (strlen($apiKey) < 1) { return false; } // Create an AlchemyAPI object. $alchemyObj = new AlchemyAPI(); $alchemyObj->_apiKey = $apiKey; $postContent = "This is an API key validation check."; try { $result = $alchemyObj->TextGetRankedNamedEntities($postContent); } catch (Exception $e) { return false; } return true; } function AlchemyAPI_TagPost() { $apiKey = get_option('alchemyapi-key'); if (strlen($apiKey) < 1) { die("You must first configure an AlchemyAPI Access Key from within your plugins settings screen."); } // Create an AlchemyAPI object. $alchemyObj = new AlchemyAPI(); $alchemyObj->_apiKey = $apiKey; $postContent = stripslashes($_POST['text']); $result = ""; $error = false; $errorMsg = ""; try { $result = $alchemyObj->HTMLGetRankedNamedEntities($postContent, "http://www.alchemyapi.com/tools/alchemytagger/?type=post"); } catch (Exception $e) { $error = true; $errorMsg = $e->getMessage(); } if ($error == false) { $resultArr = AlchemyAPI_ParseEntityResponse($result); if (count($resultArr) < 1) { $error = true; } } if ($error == true) { $error = false; try { // Extract a ranked list of named entities for this text $result = $alchemyObj->TextGetRankedNamedEntities($postContent); } catch (Exception $e) { $error = true; $errorMsg = $e->getMessage(); } } if ($error == true) { if ("Enter some text to analyze." == $errorMsg) { die("Type some text first."); } else if ("Error making API call: unsupported-text-language" == $errorMsg) { die("Type some text first."); } else { //die($errorMsg); die("Check your API key!"); } } $resultArr = AlchemyAPI_ParseEntityResponse($result); if (count($resultArr) < 1) { die("No tag suggestions at this time."); } $outTable = "{\"tags\":["; $firstT = true; foreach ($resultArr as $typeKey => $typeVal) { if ($firstT == false) { $outTable = "$outTable,"; } $firstT = false; $outTable = "$outTable{\"type\":\"$typeKey\",\"phrases\":["; $firstV = true; foreach ($typeVal as $valuesKey => $valuesVal) { if ($firstV == false) { $outTable = "$outTable,"; } $firstV = false; $segs = explode("\"", $valuesVal); $outTable = "$outTable\"$segs[0]\""; } $outTable = "$outTable]}"; } $outTable = "$outTable]}"; header('Content-type: application/json'); echo "$outTable\n"; } function AlchemyAPI_Setup() { if (function_exists('add_meta_box')) { $mode = 'normal'; $guiMode = get_option('alchemyapi-gui-mode'); if (strlen($guiMode) > 0 && $guiMode == "advanced") { $mode = 'advanced'; } $priority = 'low'; $replaceGui = get_option('alchemyapi-replace-tag-gui'); if (strlen($replaceGui) < 1 || $replaceGui == "true") { $priority = 'high'; } add_meta_box('alchemyapi', 'AlchemyTagger', 'AlchemyAPI_GUI', 'post', $mode, $priority); } else { add_action('dbx_post_sidebar', 'AlchemyAPI_GUI', 1); } add_submenu_page('plugins.php', 'AlchemyTagger Configuration', 'AlchemyTagger Configuration', 'manage_options', 'alchemytagger-config', 'AlchemyAPI_Config'); } function AlchemyAPI_Config() { if (isset($_POST['alchemyapi-key'])) { $thisKey = $_POST['alchemyapi-key']; $thisKey = trim($thisKey); update_option('alchemyapi-key', $thisKey); if (isset($_POST['alchemyapi-gui-mode'])) { update_option('alchemyapi-gui-mode', $_POST['alchemyapi-gui-mode']); } else { update_option('alchemyapi-gui-mode', 'normal'); } if (isset($_POST['alchemyapi-replace-tag-gui'])) { update_option('alchemyapi-replace-tag-gui', $_POST['alchemyapi-replace-tag-gui']); } else { update_option('alchemyapi-gui-mode', 'false'); } if (isset($_POST['alchemyapi-disamb-enabled'])) { update_option('alchemyapi-disamb-enabled', $_POST['alchemyapi-disamb-enabled']); } else { update_option('alchemyapi-disamb-enabled', 'false'); } if (isset($_POST['alchemyapi-async-enabled'])) { update_option('alchemyapi-async-enabled', $_POST['alchemyapi-async-enabled']); } else { update_option('alchemyapi-async-enabled', 'false'); } if (isset($_POST['alchemyapi-async-timeout'])) { $timeout = $_POST['alchemyapi-async-timeout']; $asyncTimeout = (int)$_POST['alchemyapi-async-timeout']; if ($asyncTimeout < 10) { $timeout = "10"; } if ($asyncTimeout > 120) { $timeout = "120"; } update_option('alchemyapi-async-timeout', $timeout); } else { update_option('alchemyapi-async-timeout', '10'); } } ?>

AlchemyTagger Configuration

AlchemyTagger automatically works in the background as you're writing new blog posts, analyzing your writing and suggesting useful categorization tags. Tags make your posts easier to navigate, better-ranked by search engines, and more!

AlchemyTagger requires an API key to operate. To create an API key, click here.


0) { $isValid = AlchemyAPI_CheckAPIKey(); } $disambOn = get_option('alchemyapi-disamb-enabled'); if (strlen($disambOn) < 1) { update_option('alchemyapi-disamb-enabled', 'true'); } $asyncOn = get_option('alchemyapi-async-enabled'); if (strlen($asyncOn) < 1) { update_option('alchemyapi-async-enabled', 'true'); } $asyncTimeout = get_option('alchemyapi-async-timeout'); if (strlen($asyncTimeout) < 1) { update_option('alchemyapi-async-timeout', '10'); } $guiMode = get_option('alchemyapi-gui-mode'); if (strlen($guiMode) < 1) { update_option('alchemyapi-gui-mode', 'normal'); } $guiMode = get_option('alchemyapi-replace-tag-gui'); if (strlen($guiMode) < 1) { update_option('alchemyapi-replace-tag-gui', 'true'); } if ($isValid == false) { ?>

API Key is *not* valid
API Key is valid!
(What is this?)

(What is this?)

Automatic tag suggestions polling frequency (in seconds): (Enter a value from 10-120)

0) { $timeout = (int)$asyncTimeout; } $replaceGui = get_option('alchemyapi-replace-tag-gui'); if (strlen($replaceGui) < 1 || $replaceGui == "true") { ?>

AlchemyTagger



Or, enter your own tags: 
Separate tags with commas