You could be seeing a great picture here
_

Charles on… anything that comes along

Thursday 9 June 2005

Filed under: — Charles @ 9:54 pm

How do I use the Amazon API to get sales rank?

The wife was on BBC TV earlier this week, talking about her new book.Jojo Moyes on BBC Breakfast TV

We then watched the “Amazon effect”, as the book’s sales ranking rose, and kept rising, as the evening went on. (Why the evening, not the day? Do people save their purchases until they get home? Do they tape BBC Breakfast and watch it at the end of the day?)

What’s frustrating, though, is that there’s not an easy way to track the sales ranking over time, at least from the UK site. Over at Kevin Kelly — Cool Tools, he points to a service called Junglescan which will do exactly that, with a graph - but only for things on the .com site.

I did write an Applescript/shell script hack that would find the sales ranking of any given book, but it really needed (grr) broadband to be useful; then you could run it at the same time each day, or every hour. I could revive it, but if anyone could point me to a pre-written bit of PHP or other code that would get the sales ranking of a book from Amazon UK, I’d be grateful.

Filed under: — Charles @ 8:03 pm

Finally! The solution to trackback spam in Wordpress (1.2)

Trackback spam is one of the most annoying things on blogs. The way it works is that the spammer apparently puts a link to a post on your site on their site (or more likely, sends a trackback message through an open proxy).

Your blog picks it up and puts an “extract” of their post on your site, attached to the relevant post. However, poker and other online time-and-money-wasting spammers will attack a blog. And in Wordpress 1.2 (I haven’t upgraded yet to 1.5) there wasn’t any way to get trackbacks passed through the normal comment-checking facility, which would normally catch all the “poker.. roulette.. slots..” junk.

But after an evening spent cursing and gritting my teeth and then surfing around various Wordpress fixes, I’ve found it. The clue (well, solution perhaps) is over at http://www.zerolives.org/backissues/2005/01/06/testing/.

Here’s what you do (as the CSS on that site is even worse than this one). This will mean nothing to anyone who’s not using Wordpress.

Open your local copy of wp-trackback.php (at the top level of your blog, along with index.php etc..

Scroll down to about line 60. There, between the lines

$comment = format_to_post($comment);
$comment_author = $author;

insert
$comment = apply_filters('post_comment_text', $comment);

so you have
$comment = format_to_post($comment);
// following line added to try to combat trackback spam
$comment = apply_filters(’post_comment_text’, $comment);
$comment_author = $author;

(the line with two // is a comment; it does nothing, but helps you navigate.)

Rename the version on the server to wp-trackback.bak - it’s only wise, in case you’ve messed up - and upload your new wp-trackback.php.

This will send the trackback text through any comment filtering system you’ve got in place. Personally I’m using Kitten’s Spaminator (though one I’ve twiddled myself; apply for it if you want, under GPL; its author hasn’t updated it for WP 1.5).

My experience shows that this does indeed trap trackback spam, sending it to moderation, although the email you get (if you choose to get email when a comment arrives, which is wise) will suggest it has been approved.

This gets around the problem of trying to stop all trackbacks, which goes too far; and of not being able to moderate them at all, which is daft, in these circumstances.

Powered by WordPress