| Text Size: |
Web 2.0 >> Common Web 2.0 Features >>
Trackback: A Guide for Implementing Trackback on Your Site
"For people who make websites" - A List Apart Magazine explores the design, development, and meaning of web content, with a special focus on web standards and best practices.
HTML Validator is a Mozilla extension that adds HTML validation inside Firefox and Mozilla. The number of errors of a HTML page is seen in the form of an icon in the status bar when browsing. The details of the errors are seen when looking the HTML source of the page.
The extension is based on Tidy and OpenSP. Both algorithms were originally developed by the Web Consortium W3C. Both algorithms are embedded inside Mozilla/Firefox and makes the validation locally on your machine, without sending HTML to a third party server.
The extension is based on Tidy and OpenSP. Both algorithms were originally developed by the Web Consortium W3C. Both algorithms are embedded inside Mozilla/Firefox and makes the validation locally on your machine, without sending HTML to a third party server.
This project aims to create an archive of user contributed clip art that can be freely used.
Starting at the beginning, this reference explains everything you need to know about using core JavaScript. It assumes you have the following basic background: a general understanding of the Internet and the World Wide Web and a good working knowledge of HTML. An excellent resource.
Edit your images on the fly online with Splashup, a web-based image editor that integrates with Flickr, Facebook, and Picasa. Splashup offers up a surprising array of image editing tools, far beyond the usual crop of resize and contrast-- you can also edit multiple images, play with filters and layers, use a variety of brushes, and more. Splashup is one of the best image editors in a long line of image editors; i.e., Picnik, Pixoh, and Resizr, to name just a few.[Lifehacker Annotation]
This website will let you:
- Create an XML sitemap format that can be submitted to Google to help them crawl your website better.
- Create a Text sitemap to submit to Yahoo.
- Create a ROR sitemap, which is an independant XML format for any search engine.
- Generate an HTML site map to allow human visitors to easily navigate on your site.
Clearspring's free Launchpad widget builder lets you easily turn your website's content into a widget which site visitors can use to place your content on all the major social media sites (MySpace, FaceBook, Google, hi5, Live, Yahoo, Wordpress, Blogger, etc.). The service also provides tracking and analysis.
This site features online text and html changing, modifying, converting tools designed to save you time making web pages or preparing text for web publication. If you've ever needed to capitalize sentences or convert line breaks to <p> or <br /> then this site can save you needless manual labor. There are other useful tools as well, like the one to uncompress html to make it readable and the ones to uppercase or lowercase text. Basically, the most common tasks that someone who works in an office or does freelance web development might encounter. Most of the tools have been created using javascript so you should be able to change large amounts of text as the processing is done on your computer instead of being limited by a server script.
When used properly, trackbacks and pingbacks are an excellent way to build links and traffic to your blog, as well as building relationships with other bloggers.
Six Apart's trackBack technical specification
Useful Resources
View all resources
Editor Favorites
- A List Apart
- HTML Validator Firefox Plugin
- Open Clip Art Library
- Core JavaScript Guide: Version 1.5
- Splashup
- XML Sitemaps Generator
- Clearspring Launchpad
- Text Fixer
Other Resources
Links to Consider
While trackback is a standard feature of the main blog software platforms, an independent-minded webmaster should consider it a feature worth adding to any site. Communication between computers sounds daunting, but as always, thanks to some open source software, it's really nothing that can't be learned and implemented fairly quickly.
Trackback can be implemented either remotely, being integrated into your CMS or whatever script(s) you use to publish content, or it can be done via a dedicated script with a form used to specify the relevant attributes. It can also use either the POST method or the GET method, though I believe that some receiving computers choose to not accept GET method trackbacks.
It should also be mentioned that trackback is anonymous by construction. This means that it is used by a lot of spammers. Blog software platforms usually do a decent job of managing this spam, especially by using Akismet (reference the useful open source Akismet PHP Class), so that is something to consider as you develop your trackback functionality.
Generally speaking, there are five variables to consider when issuing a trackback:
- trackback URI – sites that are setup to receive trackbacks usually publish a unique URI for each entry
- title – the title of your referring resource
- url – the location of your referring resource
- excerpt – explanatory text to describe your resource; it could be the entire text of your posting or just a summary of it
- blog-name – the name of the site where the resource you are referencing resides; note that this variable name illustrates how trackback traces its roots to the blog world
Implementing Trackback Functionality
There are two aspects to implementing trackback: the ability to issue a trackback and the ability to receive a trackback from others. For both, I use the PHP Trackback open source class, though I have made some modifications to enhance it which I will explain shortly.Issuing Trackbacks
How you implement the ability to issue a trackback will depend on your specific situation, but for me, I like to use theauto_discovery function of the PHP Trackback class. This function will search any text you supply for links and it will then remotely open those links and search for trackback URI(s). To illustrate, let's assume you have a form to post a blog entry. For simplicity, let's say that it includes fields for a title, a text description and for special notes or comments. You might assume that the title field will never include a reference to an external URL, but that the description and the notes fields very well may. In that case, you could write your form submission code such that you concatenate those two fields into one text variable, say
$text, and then supply that variable to the auto_discovery function. It might look something like this: // --- Form submission code
// --- do all your form processing first...
// --- Now do the trackback
// --- Instantiate the PHP Trackback class...
include (getenv('DOCUMENT_ROOT')."/trackback_cls.php");
$trackback = new Trackback('blog name', 'author', 'UTF-8');
// --- search for trackback URIs and make request if found...
$text = $_POST["description"] . " " . $_POST["notes"];
if ($tb_array = $trackback->auto_discovery($text)) {
foreach($tb_array as $tb_key => $tb_url) {
// Attempt to ping each url...
$myurl = "http://www.mydomain.com";
$pingit = $trackback->ping($tb_url, $myurl, $_POST["title"], $_POST["description"]);
if ($pingit) {
$message .= Trackback to <em>$tb_url</em> ...Succeeded";
} else {
preg_match_all('/(<message.*?</message>)/sm', $response, $err_message, PREG_SET_ORDER);
$message .= "Trackback to <em>$tb_url</em> ...failed<br />Error message: ".$err_message[0][1];
}
}
} else {
// No trackbacks in TEXT...
$message .= "No trackbacks were auto-discovered...<br /><br />n";
}
Of course, if you prefer, you could add a field to your form for the trackback URI and manually enter it. In that case you wouldn't use the
auto_discovery function but rather you would just call the ping function directly using the manually entered URI. One thing to consider is that the auto_discovery function can take a fair amount of time and isn't perfect so supplying a trackback URI manually may be better for some applications. If you do choose to use the
auto_discovery function, it's useful to know that not all blog implementations list their trackback ping URIs in the same way. Most often, such URIs are specified via Resource Description Framework (RDF). However, sometimes they are merely listed in plain text or as a hypertext link. The current version of the PHP Trackback class only looks for URIs specified via RDF so to account for non-RDF situations, I modified the class. Specifically, I added code to look for URIs that are like %trackback.php% or %.trak%. The former are common for blogs made with Wordpress and other PHP based blog platforms while the latter are used on the Microsoft Live Spaces blogs. Receiving Trackbacks
If you want to issue trackbacks, it's reasonable that you might also like to accept them, which turns out to be a more complicated proposition. Below I describe a basic system for doing this.To begin with, I assume that we will want to keep track of people issuing trackbacks to our site, so I set up a MySQL table to do this. Here is relevant SQL code to create such a table:
CREATE TABLE IF NOT EXISTS trackbacks (
trackback_ID bigint(20) unsigned NOT NULL auto_increment,
trackback_post_ID int(11) NOT NULL default '0',
trackback_title varchar(255) NOT NULL default '',
trackback_author varchar(255) NOT NULL default '',
trackback_author_url varchar(200) NOT NULL default '',
trackback_author_IP varchar(100) NOT NULL default '',
trackback_date datetime NOT NULL default '0000-00-00 00:00:00',
trackback_date_gmt datetime NOT NULL default '0000-00-00 00:00:00',
trackback_content text NOT NULL,
trackback_approved enum('0','1','spam') NOT NULL default '1',
trackback_agent varchar(255) NOT NULL default '',
PRIMARY KEY (trackback_ID),
KEY trackback_approved (trackback_approved),
KEY trackback_post_ID (trackback_post_ID)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
You might notice that I have included a field,
trackback_approved, which allows for basic moderation functionality. Given the rampant use of trackback for spamming, this is most definitely a good idea. You should notice also that it defaults to 1 which represents approved, unless it fails an Akismet spam check, which I have implemented. You can easily remove this Akismet feature or, if you want to use it, you'll need to get a free API key. If you prefer to moderate each submission you should change the default to 0 and create your own system for reviewing and approving received trackbacks. My basic implementation also checks to see if a trackback already exists to reject multiple requests. It could and probably should be improved to check for non-identical trackbacks that originate from the same source, assuming that X trackbacks in X seconds probably represents spam attempts. Finally, I provide for an email notice to be sent each time a trackback was received. You can easily modify or remove this feature.
Of course, keep in mind that I am only offering a way to handle trackback requests, but you will still need to add relevant trackback URIs on each of your website's relevant pages. If you use the files I am making available, that will always be in the format:
http://domain.com?id=x. You will also probably want to add code to pull the trackbacks from the table we created above and show them on each relevant page. Download Files
Below you can download a .zip file containing the following trackback implementation files:akismet.class.php– this is a copy of Bret Kuhns open source class. It is used to perform the Akismet spam check.db.php– this is a class from Justin Vincent I have used to setup a database connection. I don't remember where I first found it and it may be an old or more bloated class than you need. Feel free to replace it with whatever equivalent you already are using.test.php– this is a simple form that will let you specify relevant trackback fields to test out your trackback implementation.trackback.php– this file is typically placed in the root directory and handles receiving trackbacks, as described above.trackback.class.php– my modified version of the Ran Aroussi's open source PHP Trackback class. Note: this was namedtrackback_cls.phporiginally.
Latest Version: 1.1 (2007-11-08) - improved the auto-discover function. If you rely on that feature then I recommend you upgrade...

Notes
Most of the download files are well commented. The main thing to consider are the include files. If you place all of them in the same directory you should be fine, but if you prefer to split them then make sure to adjust any relevant include statements to reflect the appropriate path locations. Generally speaking, at least thetrackback.php file will be in the root directory. | Text Size: |
TrackBack URI
