comodojo/metaweblog

Legacy metaweblog-compliant rpc interface

1.0.4 2015-10-16 23:18 UTC

This package is auto-updated.

Last update: 2024-11-05 18:57:07 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License Scrutinizer Code Quality Code Coverage

A metaweblog rpc client.

This is the development branch, please do not use it in production

This lib is intended to be used as basic client for many blog platforms (such as wordpress) or to generate testing cases for rpc server.

Installation

Install composer, then:

composer require comodojo/metaweblog

Usage example

Getting recent posts from a blog:

try {

    // Create a new metaweblog instance providing address, username and password
    $mwlog = new \Comodojo\MetaWeblog\MetaWeblog( "www.example.org", "john", "doe" );

    // Get last 10 posts
    $posts = $mwlog->getRecentPosts(10);

} catch (\Exception $e) {

	/* something did not work :( */

}

Supported methods

This library supports the whole metaweblog API:

  • getPost($id): retrieve a post from weblog

  • getRecentPosts(/*optional, default 10*/ $howmany): get $howmany posts from blog

  • newPost($struct, /*optional, default true*/ $publish): create new post

  • editPost($postId, $struct, /*optional, default true*/ $publish): edit post referenced by postId

  • deletePost($postId, /*optional, default false*/ $appkey, /*optional, default false*/ $publish): delete a post referenced by postId

  • getCategories(): retrieve a list of categories from weblog

  • newMediaObject($name, $mimetype, $content, /*optional, default false*/ $overwrite): upload a new media to weblog using metaWeblog.newMediaObject call

  • getTemplate($template_type, /*optional, default false*/ $appkey): get template

  • setTemplate($template, $template_type, /*optional, default false*/ $appkey): set template

  • getUsersBlogs(/*optional, default false*/ $appkey): returns information about all the blogs a given user is a member of

Refer to comodojo/metaweblog API for more detailed informations about methods.

RPC client and transport options

The getRpcClient() method allows access to rpc client options (and also transport options).

For example, to get recent post from a blog listening on port 8080:

try {

    // Create a new metaweblog instance providing address, username and password
    $mwlog = new \Comodojo\MetaWeblog\MetaWeblog( "www.example.org", "john", "doe" );

    $mwlog->getRpcClient()->getTransport()->setPort(8080);

    // Get last 10 posts
    $posts = $mwlog->getRecentPosts(10);

} catch (\Exception $e) {

	/* something did not work :( */

}

Other setters/getters

  • Get/set blog ID

        // Get current blog ID
        $id = $mwlog->getId()
    
        // Set current blog ID
        $mwlog->setId(2);
  • Get/set encoding

        // Get current encoding
        $enc = $mwlog->getEncoding()
    
        // Set current encoding
        $mwlog->setEncoding('utf-8');

Documentation

Contributing

Contributions are welcome and will be fully credited. Please see CONTRIBUTING for details.

License

comodojo/metaweblog is released under the MIT License (MIT). Please see License File for more information.