Codeigniter Trackback Class Library


Codeigniter Trackback Class Library – We can load trackback class library using $this->load->library(‘trackback’);. This library provide various functions that are used to enable you to send and recieve trackback data. Here in this tutorial, we are going to explain how to use trackback class library.


Codeigniter trackback class library | Example

Let us understand how trackback class library works in codeigniter with examples.

Load trackback class library

First load trackback class library to use its functions, this library can be loaded simply as below-

How to load trackback class library:

$this->load->library('trackback');

Functions:-

There are following functions available in trackback class library. Now we will explain.

  • 1. Sending Trackbacks.
  • 2. Creating a Trackback Table.
  • 3. Processing a Trackback.

1. Sending Trackbacks.

Here is simple demo of sending trackbacks.

Syntax of sending trackbacks function.

<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class trackbacks_controller extends CI_Controller 
{
public function track()
{
$this->load->library('trackback');
$tb_data = array(
'ping_url'  => 'http://example.com/trackback/456',
'url'       => 'http://www.my-example.com/blog/entry/123',
'title'     => 'The Title of My Entry',
'excerpt'   => 'The entry content.',
'blog_name' => 'My Blog Name',
'charset'   => 'utf-8'
);
if ( ! $this->trackback->send($tb_data))
{
echo $this->trackback->display_errors();
}
else
{
echo 'Trackback was sent!';
}
}
}
?>

Tracksback can be sent from any of your controller using code.

Description of example array data.

  • 1. ping_url : Ping_url is a reciever url address where you want to send tracksback.
  • 2. url : this is sender url address where we can seen blog entry.
  • 3. title : Title of your blog entry.
  • 3. excerpt : The content of your blog entry.
  • 3. blog_name : name of your blog
  • 3. charset : The character encoding your blog is written in.

Advertisements

Add Comment

📖 Read More