Search code examples
phptrackbackpingback

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?


Solution

  • 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.