PHP code example of comodojo / metaweblog

1. Go to this page and download the library: Download comodojo/metaweblog library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

comodojo / metaweblog example snippets


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 :( */

}


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 :( */

}


        // Get current blog ID
        $id = $mwlog->getId()

        // Set current blog ID
        $mwlog->setId(2);

    

        // Get current encoding
        $enc = $mwlog->getEncoding()

        // Set current encoding
        $mwlog->setEncoding('utf-8');