Difference between revisions of "RSS API"

From GeeklogWiki
Jump to: navigation, search
m (Cosmetics)
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
For a plugin to use the builtin RSS content syndication it needs to implement three functions in functions.inc.
+
(Added in Geeklog 1.3.9)
  
'''plugin_getfeednames_pluginname()
+
For a plugin to use the built-in RSS content syndication it needs to implement three functions in <tt>functions.inc</tt>.
plugin_getfeedcontent_pluginname()
+
 
plugin_feedupdatecheck_pluginname()'''
+
'''plugin_getfeednames_pluginname()'''<br/>
 +
'''plugin_getfeedcontent_pluginname()'''<br/>
 +
'''plugin_feedupdatecheck_pluginname()'''
  
 
where pluginname is the name of the plugin.
 
where pluginname is the name of the plugin.
Line 10: Line 12:
 
== plugin_getfeednames_pluginname ==
 
== plugin_getfeednames_pluginname ==
  
The first function '''plugin_getfeednames_pluginname()'''
+
The first function '''plugin_getfeednames_pluginname()''' receives no parameters and returns a multidimensional associative array of id/name pairs where 'id' is an integer representing the plugins internal id and 'name' is what the user will see. Thus the plugin will have code like this:
receives no parameters and returns a multidimensional associative array of id/name pairs where 'id' is an integer representing the plugins internal id and 'name' is what the user will see. Thus the plugin will have code like this:
+
 
 +
<pre>
 +
function plugin_getfeednames_pluginname()
 +
{
 +
    $feed = array(
 +
        array(
 +
          'id'      => 1,
 +
          'name'  => 'Name of Feed'
 +
        ),
 +
        array(
 +
        'id'        => 2,
 +
        'name'  => 'Name of another feed'
 +
        )
 +
    );
  
function plugin_getfeednames_pluginname() {
+
     return $feed;
$feed = array(
 
     array(
 
      'id'      => 1,
 
      'name'  => 'Name of Feed'
 
    ),
 
    array(
 
    'id'        => 2,
 
    'name'  => 'Name of another feed'
 
    )
 
);
 
return $feed;
 
 
}
 
}
 +
</pre>
  
  
 
== plugin_getfeedcontent_pluginname ==
 
== plugin_getfeedcontent_pluginname ==
  
The second function '''plugin_getfeedcontent_pluginname()'''
+
The second function '''plugin_getfeedcontent_pluginname()''' receives three parameters: $feed, $link, $update_data. The plugin is expected to return a multidimensional associative array holding the content of the feed and to fill in 'link' (some link that represents the same content on the site as that in the feed) and 'update_data' (to be stored for later up-to-date checks. The function will have some code like this (note that this is pseudo-code, not real PHP code):
receives three parameters: $feed, $link, $update_data.
+
 
The plugin is expected to return a multidimensional associative array holding the content of the feed and to fill in 'link' (some link that represents the same content on the site as that in the feed) and 'update_data' (to be stored for later up-to-date checks. The function will have some code like this:
+
<pre>
 +
function plugin_getfeedcontent_pluginname()
 +
{
 +
    global $_CONF;
  
function plugin_getfeedcontent_pluginname() {
+
    $link = $_CONF['site_url'] . '/pluginname/index.php';
global $_CONF;
+
    $update_data = time();
 +
    $content = array();
 +
    foreach ($ARRAY OF DATA as $s) {
 +
        $item = array(
 +
            'title' => $s,
 +
            'link'  => $_CONF['site_url'] . '/pluginname/index.php'
 +
            'text'  => $StoryText
 +
            'uid'  => $UserID
 +
            'date'  => $StoryDate
 +
            'format'=> $format  // either 'text' or 'html'
 +
        );
 +
        $content[] = $item;
 +
    }
  
$link = $_CONF['site_url'] . '/pluginname/index.php';
+
     return $content;
$update_data = time();
 
$content=array();
 
foreach($ARRAY OF DATA as $s) {
 
  $item = array(
 
      'title' => $s,
 
      'link'  => $_CONF['site_url'] . '/pluginname/index.php'
 
      'text'  => $StoryText
 
      'uid'  => $UserID
 
      'date'  => $StoryDate
 
      'format'=> $format  #Either 'text' or 'html'
 
     );
 
    $content[]=$item;
 
}
 
return $content;
 
 
}
 
}
 +
</pre>
  
  
 
== plugin_feedupdatecheck_pluginname ==
 
== plugin_feedupdatecheck_pluginname ==
  
The final function '''plugin_feedupdatecheck_pluginname()'''
+
The final function '''plugin_feedupdatecheck_pluginname()''' receives $feed, $topic, $update_data, $limit where
receives $feed, $topic, $update_data, $limit where <br/>
+
* $feed == feed number
$feed == feed number <br/>
+
* $topic == plugin id for feed
$topic == plugin id for feed <br/>
+
* $update_data == is data stored by the previous function
$update_data == is data stored by the previous function<br/>
+
* $limit == number of items to include (configurable in editor)
$limit == number of items to include (configurable in editor)<br/>
 
  
 
The function returns true if the feed is up to date and false otherwise.
 
The function returns true if the feed is up to date and false otherwise.
Line 69: Line 75:
  
 
[[User:Tomw|TomW]]
 
[[User:Tomw|TomW]]
 +
 +
 +
[[Category:Plugin Development]]

Latest revision as of 18:15, 24 May 2009

(Added in Geeklog 1.3.9)

For a plugin to use the built-in RSS content syndication it needs to implement three functions in functions.inc.

plugin_getfeednames_pluginname()
plugin_getfeedcontent_pluginname()
plugin_feedupdatecheck_pluginname()

where pluginname is the name of the plugin.


plugin_getfeednames_pluginname

The first function plugin_getfeednames_pluginname() receives no parameters and returns a multidimensional associative array of id/name pairs where 'id' is an integer representing the plugins internal id and 'name' is what the user will see. Thus the plugin will have code like this:

function plugin_getfeednames_pluginname()
{
    $feed = array(
        array(
          'id'       => 1,
          'name'  => 'Name of Feed'
        ),
        array(
         'id'        => 2,
         'name'   => 'Name of another feed'
        )
    );

    return $feed;
}


plugin_getfeedcontent_pluginname

The second function plugin_getfeedcontent_pluginname() receives three parameters: $feed, $link, $update_data. The plugin is expected to return a multidimensional associative array holding the content of the feed and to fill in 'link' (some link that represents the same content on the site as that in the feed) and 'update_data' (to be stored for later up-to-date checks. The function will have some code like this (note that this is pseudo-code, not real PHP code):

function plugin_getfeedcontent_pluginname()
{
    global $_CONF;

    $link = $_CONF['site_url'] . '/pluginname/index.php';
    $update_data = time();
    $content = array();
    foreach ($ARRAY OF DATA as $s) {
        $item = array(
            'title' => $s,
            'link'  => $_CONF['site_url'] . '/pluginname/index.php'
            'text'  => $StoryText
            'uid'   => $UserID
            'date'  => $StoryDate
            'format'=> $format  // either 'text' or 'html'
        );
        $content[] = $item;
    }

    return $content;
}


plugin_feedupdatecheck_pluginname

The final function plugin_feedupdatecheck_pluginname() receives $feed, $topic, $update_data, $limit where

  • $feed == feed number
  • $topic == plugin id for feed
  • $update_data == is data stored by the previous function
  • $limit == number of items to include (configurable in editor)

The function returns true if the feed is up to date and false otherwise.

Feed files will always be stored in the directory specified by $_CONF['rdf_file'].

TomW