17 August 2009
Sending a trackback will take place in the admin side of your website when you submit a blog entry.
In your admin area you will often have a field to enter trackback URLs.
When you then click submit a trackback will be sent to each of these trackback URLs.
The receiving trackback URL will then send you a success or error response to notify you of the trackback status.
Once the blog entry has been submitted I save all the blog data to the database, along with the trackback URLs that you want to send to.
I personally then have a separate page that I then go to which carries out the trackbacks after getting all the trackback URLs back out of the database where we just saved them.
Here's my code which sends the trackbacks:
if (isset($_REQUEST['id'])) //Get the id of the blog having the tracback sent to it
$query = "SELECT blog_id,description,ping_links,title,link FROM blog WHERE live = 'on' AND id = '" . $_REQUEST['id'] . "'"; //Get the blog information to send
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$site_query = "SELECT name FROM site WHERE name <> '' LIMIT 1";
$site_result = mysql_query($site_query);
$site = mysql_fetch_array($site_result);
$title = $row['title']; //The title of the blog
$excerpt = $row['description']; //The blog description
$url = “http://www.peternichol.com/blog/entry/" . $row['link'] . "/"; //The blog URL
$blog_name = $row['title']; //Not too sure on the difference between this and the $title variable, but I've put the blog title again
$trackback_url = "http://www.peternichol.com/entry/trackback/" . $_REQUEST['id'] . "/"; //The trackback URL for this particular blog entry – although I don't think this is used on outgoing trackbacks
$ping_servers = explode("n",$row['ping_links']); //From the trackback URLs it separates them (one per line)
foreach ($ping_servers as $server) //Loop each of the trackback URLs
$trackbackData = array( //Set the trackback data
'id' => "",
'title' => $title,
'excerpt' => $excerpt,
'url' => $url, //My blogs URL
'blog_name' => $blog_name,
'trackback_url' => $server
//new trackback instance
$trackback = new Services_Trackback();
//set opbject properties
foreach ($trackbackData as $k => $v)
$ret = $trackback -> send();
//Trackback sent successfully
Please leave a comment using the form provided.