The Simplest BlogCFC Post Code

I wrote an app that I use to allow BlogCFC posts via e-mail. This particular blog is an internal Adobe blog, and anyone with a valid Adobe LDAP login can post to it. (I also wrote some code that updates Ray’s login code so as to update tblUsers table with new users as needed).
BlogCFC has grown into quite a hefty app, but much of the code is actually used for rendering UI with locale support and more. The actual code needed to make a post (this is what gets called by the core of the BlogMail bot after it has validated the user and extracted the body and subject) is very simple. And in case anyone else wants it, this is all you need:

The username is needed to “login” so that the blog entry has a valid owner (BlogCFC relies on ColdFusion logins for this, and thus the ). The makeTitle() call is actually optional, if you don’t want an SEO type friendly URL you can skip that. addEntry() does the actual work of adding the blog entry. And assignCategories() passes the category list. (My bot code scans the subject and body for keywords and builds that category list automatically).
So, if you need to programmatically add entries to BlogCFC, instead of hacking the database tables (never a good idea), this code should be all you need.

3 responses to “The Simplest BlogCFC Post Code”

  1. Shane Zehnder Avatar
    Shane Zehnder

    It’s funny that you just posted this as I was just mulling much the same thing around. Thanks Ben!

  2. barry.b Avatar

    so how did you send the email to the CF server? did the emails go to a mailbox and you used CFPOP on a sched task to retrieve it?

  3. Ben Forta Avatar
    Ben Forta

    Barry, yes, exactly. I wanted team members to be able to write up entries and reports while disconnected, perhaps on flights back. They send these to an internal mailbox, and a scheduled event picks them up for processing.
    — Ben

Leave a Reply