Using HTTP outletsComments posted to tags may be sent to an HTTP outlet. An HTTP outlet will send via HTTP POST the tag name and comment to a URL of your choosing. For example, here is a simple PHP script that receives and displays the outlet message: <?php if ( $_SERVER['REQUEST_METHOD'] == "POST" ) { $tagname = $_POST['tag']; } else { ?>$comment = $_POST['comment']; $theFile = "/tmp/taglets.txt"; $fh = fopen($theFile, 'a+') or die("Can't open file"); $record = $tagname . "|" . $comment . "\n"; fwrite($fh, $record); fclose($fh); <html> }<head> <title>Taglets.org comment tracker</title> </head> <body> <?php $theFile = "/tmp/taglets.txt"; $lines = file($theFile); foreach($lines as $line_num => $line) { echo $line . "<br>"; } ?> </body> </html> <?php ?> If the script is accessed via POST, the tag name and comment are appended to a text file /tmp/taglets.txt. If the script is accessed via HTTP GET, the file contents are rendered to html. Wrapping public API calls in the Groovy scripting languageTaglets features an open source reference implementation written in Java. Developers can wrap these calls in Groovy, and powerful scripting language that integrates well with existing Java classes.For example, to post a comment to a tag using Groovy and the Java API, /* Typical use of Groovy to drive a Java API call This example is a work in progress with respect to long options: http://www.nabble.com/How-much-of-CliBuilder-does-work--td16111825.html For now use short option names. */ import org.taglets.pub.tags.* import org.taglets.exception.* def cli = new CliBuilder(usage: 'groovy tagcomment.groovy -tc [h]') cli.h(longOpt: 'help', 'usage information') cli.t(argName:'tagname', longOpt:'tagname', args:1, required: true, 'tag name') cli.c(argName:'comment', longOpt:'comment', args:1, required: true, 'comment (first 124 chars used)') def opt = cli.parse(args) if (!opt) { return } if( opt.h ) { cli.usage } tagName = opt.t comment = opt.c try { TagCommentClient client = new TagCommentClient() TagCommentResponse response = client.postComment(tagName, comment) println "Comment post HTTP response code: ${response.getResponseCode()} ${response.getResponseMessage()}" println "Comment post succeeded: ${response.succeeded}" println "Headers:" def headers = response.getHeaderFields() headers.each { header -> println " ${header}" } } catch (TagletsException e) { e.printStackTrace(); } Wordpress PluginWe've created a Wordpress plugin called Taglets Feeder that sends comments on referenced tags to taglets.org when you publish a post on your blog. |