Language: FoxPro
Using Akismet with Visual Foxpro
*** Setup Transaction lcAkismetKey = "" &&Get your API key at http://wordpress.com/signup/ and click "Just a username, please." lcBlogURL = Alltrim(Request.Form("BlogURL")) &&Blog URL lcUserIP = Alltrim(Request.GetIPAddress()) lcUserAgent = Alltrim(Request.GetBrowser()) lcCommentType = Alltrim(Request.Form("UserType")) &&Choices: blank, comment, trackback, pingback, or a made up value like "registrant". lcCommentAuthor = Alltrim(Request.Form("UserName")) &&FYI: 'viagra-test-123' forces true a.k.a. "spam" lcAuthorEmail = Alltrim(Request.Form("UserEmail")) lcAuthorUrl = Alltrim(Request.Form("UserWebsite")) lcComment = URLEncode(Alltrim(Request.Form("UserComment"))) *** Authenticate Key oHTTP=Createobject("wwHttp") oHTTP.AddPostKey("key",lcAkismetKey) oHTTP.AddPostKey("blog",lcBlogURL) oHTTP.cExtraHeaders = oHTTP.cExtraHeaders + "User-Agent: West Wind Web Connection/4.68 | Akismet/1.11" + Chr(13) + Chr(10) lcHTML = oHTTP.HTTPGet("http://rest.akismet.com/1.1/verify-key","","") oHTTP.HTTPClose() oHTTP = Null *** If Alltrim(Lower(lcHTML)) = "valid" &&Key Authenticates 'valid', check comment. oHTTP=Createobject("wwHttp") oHTTP.AddPostKey("blog", lcBlogURL) oHTTP.AddPostKey("user_ip", lcUserIP) oHTTP.AddPostKey("user_agent", lcUserAgent) oHTTP.AddPostKey("comment_type", lcCommentType) oHTTP.AddPostKey("comment_author", lcCommentAuthor) oHTTP.AddPostKey("comment_author_email", lcAuthorEmail) oHTTP.AddPostKey("comment_author_url", lcAuthorUrl) oHTTP.AddPostKey("comment_content", lcComment) *** Returns 'true' if spam, 'false' if not spam. lcHTML = oHTTP.HTTPGet("http://"+lcAkismetKey+".rest.akismet.com/1.1/comment-check","","") oHTTP.HTTPClose() oHTTP = Null Do Case Case lcHTML = "true" Response.WriteLn(["Key Authenticated. Comment is Spam."]) Case lcHTML = "false" Response.WriteLn(["Key Authenticated. Comment is NOT Spam."]) Otherwise Response.WriteLn(["Key Authenticated. Spam Status Unknown."]) Endcase Else &&Key Authenticates 'invalid', comment NOT checked Response.WriteLn(["Key NOT Authenticated. Spam Status Unknown."]) Endif
Tags:
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

