Keyworderer
From Plings Info
This script automagically adds keywords to Plings activities by checking activitiy titles and descriptions against a published list of credible keywords for Positive Activities.
<?php # Copyright (c) 2010 Ben Webb <bjwebb67@googlemail.com> # Released as free software under the MIT license. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE /* This script automagically adds keywords to Plings activities by checking activity titles and descriptions * against a published list of credible keywords for Positive Activities. */ //Set some variables //$outputkey: Plings development API key (or your own!). See: http://plings.info/wiki/index.php/API_Keys //$inputkey: You need you're own key to edit your own data //$orgid: a variable to declare your organisation ID required to fetch your own data from the Plings API $outputkey = "5A605302-FC5BC526-4473C6AB-B4D9009B-RQMKMLDM"; $inputkey = "REMOVED"; $orgid = "16916"; //Create a new SoapClient $client = new SoapClient("http://feeds.plings.net/services/activities.php?wsdl"); //Authenticate with the input system. See: http://plings.info/wiki/index.php/Plings_Input_API_-_SOAP print_r($client->register($inputkey)); //Grab data from the Plings Output API. See: http://plings.info/wiki/index.php/Plings_Output_API $feed = "http://feeds.plings.net/xml.activity.php/14/o/$orgid/?APIKey=" . $outputkey; //Parse the XML $plingsxml = simplexml_load_file($feed); // In the meantime...get the list of acceptable keywords from the wiki page at: http://plings.info/wiki/index.php/Keywords //and place them into an array $xml = simplexml_load_file("http://plings.info/wiki/index.php/Special:Export/Keywords"); $keywordlist = $xml->page->revision->text; $keys = array(); foreach (explode("\n", $keywordlist) as $line) { if (preg_match("/\* (.*)/", $line, $m)) { $keys[] = trim($m[1]); } } // Loop throught all activities in the XML // We check the Title/Name of each activity and the Details/Descreption for keywords from our list // Finally we add them using the addActivityKeywords SOAP methos foreach ($plingsxml->activities->activity as $activity) { $id = $activity->attributes()->id; if (empty($activity->keywords->keyword)) { // If keywords already exist, we won't add any more as we assume someone has already done a good job! $text = $activity->Name . " " . $activity->Details; foreach ($keys as $keyword) { $keyword = strtolower($keyword); if (stripos($text, $keyword)) { print_r($client->addActivityKeyword($id, (string)$keyword)); echo "key ".$id." ".$keyword."<br/>\n"; } } } } ?>

