views:

201

answers:

3
+2  Q: 

Trackbacks in PHP

I'm writing a custom blog engine and would like to have trackbacks similar to Wordpress. I could look at the Wordpress source, but I'd really prefer a tutorial of some sort and so far I haven't been able to find one. Are there any good tutorials for implementing trackbacks or pingbacks in PHP5?

+3  A: 

Implementing trackbacks isn't that hard at all. Here you can find the official specification and an example at the bottom.

okoman
A: 

Dunno what trackbacks are, all I've noticed of them is that they clutter up websites with messy blocks of text, often interpersed with article comments.

But if they allow you to see who is linking to you in real time without log analysis:

You could use the HTTP-Referer (sic) header to see if people have linked to your article. Each article would have a map of these referrers (and a count, so you can organise by popularity). You then implement a basic crawler that visits new referrers to scrape content.

I'm sure there's a third party implementation available as well. Or a specification. As the other poster has linked to, so, err, ignore this.

JeeBee
+2  A: 

Trackbacks are fine, but they're very prone to spam, since there's no verification of their origin. You use a simple discovery method to find the trackpack entrypoint; look for RDF in the target site's source. Then it's simply a RESTful POST request to the destination site's trackback entrypoint passing the requisite trackback information. The specification linked by Sebastian Hörl should give you plenty of information for that.

Pingbacks are a bit more complex, because they require both XMLRPC and a linkback. So while you can just use REST calls to send anonymous trackbacks to any site, sites that you pingback will look at your site to determine whether you're actually linking to the pinged page.

Also, implementing Pingback on the receiving end is a little more complicated, because you have to verify the ping. I suppose you don't have to, but it would be foolish not to, otherwise it would be susceptible to the same spamming techniques as Trackbacks.

The Pingback specification has all the information you need to get that implementation off the ground.

Another recommendation is rather than wade through the inevitably dense and spaghetti-ish WordPress Pingback code, have a look at Habari's self-contained Pingback implementation, which isolates some of the key features of the task into more easily digestible units.

ringmaster