Api

Atom Publishing Protocol

bmPress aim to support Atompub as its primary API.

For now, Wordpress needs to be patched with the following patches so that everything works correctly. This patches allow plugins to process Atompub requests and add tags handling in the Wordpress Atompub backend:

  • #8829: Use 'the_category_rss' template function in Atompub backend (integrated in WP 2.8)
  • #8828: Tags and Categories are undifferentiable in Atom and RSS feeds
  • #8827: Add 'app_create_post' and 'app_put_post' hooks in Atompub backend (integrated in WP 2.8)
  • #8826: Support 'atom_ns' 'atom_head' & 'atom_entry' hooks in Atompub backend

Once done, you can use Atompub naturally to read, add, update and delete entries.

The only details to know are that:

  • the main URL should be expressed using an Atom link with rel='related'
  • tags are Atom categories with a scheme='urn:tag' or containing '/tag/'
<entry xmlns="http://www.w3.org/2005/Atom">
  <title>bmPress</title>
  <content type="text">social bookmarking for the Wordpress platform</content>
  <link rel="related" type="text/html" href="http://bmpress.org/"/>
  <category scheme="http://demo.bmpress.org/category/" term="blogmarks" label="Blogmarks"/>
  <category scheme="urn:tag" term="social-bookmarking" label="social bookmarking"/>
  <category scheme="http://demo.bmpress.org/tag/" term="wordpress" label="wordpress"/>
</entry>

Examples using Zend Framework

Adding a bookmark

$authenticatedHttpClient = new Zend_Http_Client();
$authenticatedHttpClient->setAuth('joe', 'XXXXXX');
$gdata = new Zend_Gdata($authenticatedHttpClient);
 
$baseUrl = 'http://demo.bmpress.org';
$endpoint = $baseUrl . '/wp-app.php/posts';
 
$entry = $gdata->newEntry();
$entry->title = $gdata->newTitle('bmPress');
$entry->content = $gdata->newContent('social bookmarking for the Wordpress platform')->setType('text');
$entry->setLink(array(
  new Zend_Gdata_App_Extension_Link('http://bmpress.org/', 'related')
));
$entry->setCategory(array(
  new Zend_Gdata_App_Extension_Category('wordpress', $baseUrl . '/tag/'),
  new Zend_Gdata_App_Extension_Category('social-bookmarking', 'urn:tag', 'social bookmarking')
));
 
$result = $gdata->insertEntry($entry, $endpoint);

XML-RPC

metaWeblog.newPost

To post an a new bookmark, you can use this method with the following struct parameters:

  • title: the bookmark title
  • description: the bookmark description/content
  • mt_keywords: the bookmark tags, comma separated
  • custom_fields: an array containing this parameters
    • key: related, value: the bookmark main URL
    • key: via, value: the bookmark via URL
    • key: screenshot, value: the bookmark thumbnail URL

Example using the Zend Framework:

$client = new Zend_XmlRpc_Client('http://demo.bmpress.org/xmlrpc.php');
 
$client->call('metaWeblog.newPost', array(
  0,              // 0 - blog ID
  'joe',          // 1 - login
  'XXXXXX',       // 2 - password
  array(          // 3 - content struct
    'title'           => 'bmPress',                                         // title
    'description'     => 'social bookmarking for the Wordpress platform',   // content
    'mt_keywords'     => 'wordpress, social bookmarking',                   // tags
    'custom_fields'   => array(                                             // metas
      array('key' => 'related', 'value' => 'http://bmpress.org/')           // - URL
    ) 
  ),
  true // 4 - publish (draft if not true)
));

Delicious API

Not ready yet.

api.txt · Last modified: 2009/03/16 09:14 by znarfor

bmPress is an h6e project. email: contact at h6e.net