Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added Akismet YQL table

  • Loading branch information...
commit 25026b7891ce70d57c6db3af5ab977e98d69b215 1 parent 7623935
César D. Rodas crodas authored

Showing 1 changed file with 49 additions and 0 deletions. Show diff stats Hide diff stats

  1. +49 0 akismet/akismet.xml
49 akismet/akismet.xml
... ... @@ -0,0 +1,49 @@
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<table xmlns="http://query.yahooapis.com/v1/schema/table.xsd">
  3 + <meta>
  4 + <author>César Rodas</author>
  5 + <description>Check if a comment-text is SPAM</description>
  6 + <documentationURL>http://akismet.com/development/api/</documentationURL>
  7 + <sampleQuery>select * from {table} where key='123456' and text in ('enlarge your penis', 'buy free viagra! viagra for free', 'Nice post I agree with you')</sampleQuery>
  8 + </meta>
  9 + <bindings>
  10 + <select itemPath="" produces="XML">
  11 + <urls>
  12 + <url></url>
  13 + </urls>
  14 + <inputs>
  15 + <key id='text' type='xs:string' paramType='variable' required="true" />
  16 + <key id='key' type='xs:string' paramType='variable' required="true" />
  17 + <key id='blog' type='xs:string' paramType='variable' />
  18 + <key id='ip' type='xs:string' paramType='variable' />
  19 + <key id='author' type='xs:string' paramType='variable' />
  20 + <key id='email' type='xs:string' paramType='variable' />
  21 + </inputs>
  22 + <execute><![CDATA[
  23 + if (!ip) {
  24 + /* Fake IP */
  25 + ip = "127.0.0.2";
  26 + }
  27 + if (!author) {
  28 + author = "";
  29 + }
  30 + if (!email) {
  31 + email="";
  32 + }
  33 + if (!blog) {
  34 + blog="";
  35 + }
  36 + var url = "http://" + key + ".rest.akismet.com/1.1/comment-check";
  37 + var post = "blog=" + blog + "&user_ip=" + ip + "&comment_author=" + author + "&comment_author_email=" + email + "&comment_author_url=&comment_content=" + text;
  38 +
  39 + var resp = y.rest(url).post(post).response;
  40 +
  41 + var spam = resp.substr(0,4) == 'true';
  42 +
  43 + response.object = <result><text>{text}</text>
  44 + <is_spam>{spam}</is_spam></result>;
  45 +
  46 + ]]></execute>
  47 + </select>
  48 + </bindings>
  49 +</table>

0 comments on commit 25026b7

Please sign in to comment.
Something went wrong with that request. Please try again.