More Google API hacks for Movable Type

8

Wow, I was pleasantly surprised with the rush of positive feedback from today’s Google API hack for Movable Type users. A number of people asked for some new features, and given that it was only anoither 7 lines of perl code or so, I coded it up!
The new patch to MT 2.11 adds the following new features to the MTGoogleSearch tag. It adds the following new properties that will change the behavior of the tag:

  • title=”1″ : This will cause the google search query to be the title (MTEntryTitle) of your current blog entry
  • excerpt=”1″ : This will cause the google serch query to be the entry excerpt (MTEntryExcerpt) of the current blog entry

Those two properties are mutually exclusive (along with the current query=”" and related=”1″ properties).
In addition, if you use strip_html=”1″ inside the MTGoogleSearch tag, it will remove any html that Google replies with, including <b> tags that surround the search query terms.
This is a patch on the default build of Movable Type 2.11. If you’ve already installed my previous patch, it might be easier to just back out the patch and install this one.
By the way, I haven’t done a lot of testing with the MTEntries query code (entries=”1″) so if you do use it, please send me feedback.

Share

Related posts:

  1. A great new use of the Google API and SOAP
  2. Related Stories patch accepted for Movable Type 2.2, Dave Winer’s comments
  3. Google web results significantly different from API
  4. Hacking Google, and a new easter egg
  5. Hey, that’s my telephone number on Google!
Posted in: Uncategorized

This article has 8 comments

  1. Urban 06/20/2002, 5:29 am:

    I guess I havn’t set up the SOAP module correctly, but I get this error when trying to rebuild my blog:
    An error occurred:
    Can’t call method “send_receive” on an undefined value at C:/Perl/site/lib/SOAP/Lite.pm line 93.
    MT::App::CMS=HASH(0x1a657c8) Use of uninitialized value in sprintf at C:/Perl/site/lib/SOAP/Lite.pm line 1457.

  2. Chuck Welch 06/20/2002, 8:05 am:

    OK…the new excerpt and strip_html didn’t work for me.
    Using excerpt=”1″ I get:
    500 Internal Server Error at /mt/lib/MT/Template/Context.pm line 1259
    And it looks as though strip_html calls remove_html (if I read correctly) and Ben Trott said that command may not work…
    Ben: “The only thing I can think of is that may be due to the XML modules installed on your server. If your server is using the XML::Parser::Lite module (part of SOAP::Lite), it doesn’t decode entities, and that could be the issue. The solution is to get your server admin to install XML::Parser. ”
    And he’s right…my server uses XML::Parser::Lite
    I hope that helps your debugging…

  3. Chuck Welch 06/20/2002, 8:05 am:

    OK…the new excerpt and strip_html didn’t work for me.
    Using excerpt=”1″ I get:
    500 Internal Server Error at /mt/lib/MT/Template/Context.pm line 1259
    And it looks as though strip_html calls remove_html (if I read correctly) and Ben Trott said that command may not work…
    Ben: “The only thing I can think of is that may be due to the XML modules installed on your server. If your server is using the XML::Parser::Lite module (part of SOAP::Lite), it doesn’t decode entities, and that could be the issue. The solution is to get your server admin to install XML::Parser. ”
    And he’s right…my server uses XML::Parser::Lite
    I hope that helps your debugging…

  4. Chuck Welch 06/20/2002, 8:12 am:

    Sorry about that….I didn’t mean to post multiple times, but when I post I didn’t get a result page. Instead I get the following error message:
    500 Internal Server Error on context.pm line 1259

  5. Dave Sifry 06/20/2002, 8:58 am:

    Hmmm, I wonder if I overdrew my Google allocation for the day, or if Google had an outage of their SOAP APIs. That server error occurs on the SOAP call to Google.
    If you’re using XML::Parser::Lite, then you may be SOL because of the issue you mentioned above. The workaround would be to rewrite remove_html or install the full XML modules in your home directory. strip_html is more selective than remove_html – the remove_html property removes ALL html resulting from the tag, which isn’t what we want – strip_html removes html from the results of the Google search only.
    Let’s see if it wasn’t a burp in Google’s service or in my API key, too.

  6. Jason Jordan 06/20/2002, 9:23 am:

    Yup…
    perl -MCPAN -e ‘install XML::Parser’
    fixed up the line 1259 error for me… 8-)

  7. Dave Sifry 06/23/2002, 5:32 pm:

    Cool, I just heard back from one of the Movable Type developers that this new feature will be included in their 2.2 release. Dave Winer also links to this, along with a macro for radio to add a “Google It” link to any radio weblog. Actually, that’s not really what this patch does, Dave. For a better Radio Macro, see Jake Savin’s cool hack.

  8. zip codes 03/15/2003, 4:14 pm:

    nice article, keep up the good work. lookup zip code

Across the Web

  • Facebook
  • Twitter
  • Flickr
  • Youtube

Twitter

Javascript needs to be installed to view the twitterfeed. Get Javacript

Follow Me on Twitter