Implementing Pingback in alriyadh.com
By Rayed
Pingback is a method for Web authors to request notification when somebody links to one of their documents. This enables authors to keep track of who is linking to, or referring to their articles.
Implementing Pingback feature is very easy, you need to add the following code to your template:
<link rel="pingback" href="http://www.alriyadh.com/php/xmlrpc/" />
This code will make other blogging software notify your software that it is linking to it, It do this by sending “pingback.ping” XML-RPC request to the given URL, when you get the notification you can add it to the database, email it, or do what ever you want with it.
This is a sample code of the XML-RPC server using Incutio XML-RPC Library for PHP, It accept “pingback.ping” request, send an email to you with the source URL, and destionation URL: function pingBack($args) {
$body = ‘Ping from: ‘.$args[0]
.‘Ping to: ’ . $args[1];
mail(‘user@domain.com’, ‘Subject: Ping Back’, $body);
return ‘Thank you’; } $server = new IXR_Server(array(
‘pingback.ping’ => ‘pingBack’,
< ?php
include 'IXR_Library.inc.php';
));
?>
TrackBack is another protocol that is similar to Pingback, may be I’ll write something for it as well.
Wikipedia links:
I’ve added Pingback to alriyadh.com and I’ll update with any intersting stuff.
Update: So far and after 36 ours I didn’t get any pingback 🙂
Update: I got my first pingback from SaudiGeek: http://www.saudigeek.com/?p=124, SaudiGeek I hope you don’t mind using you in my example.