Ngeblog 0.0.3

Another version? gee, this is fast. Well, what can i say, i got quick response too to my previous release. So, i’ll be doomed if i don’t change it sooner.

Thanks to Bill for his sugestion and code tester. So here you go.

Multiple Blogs

The problem with previous version of Ngeblog is you can’t choose which blogs will you manipulate, since i forgot about the fact that Blogger allows you to have multiple blogs in an account.

So i added a new method getBlogInfo() which will retrieve the information about your blogs in two dimensional array. All you have to do is write this simple codes,

<?php

  require_once "Ngeblog.php";

  $myblog = new Ngeblog("yourusername","yourpassword");

  $bloginfo = $myblog->getBlogInfo();

  echo "<pre>";
  print_r($bloginfo);
  echo "</pre>";

?>

The output would be something like this:

Array
(
    [0] => Array
        (
            [blogid] => 36455441
            [title] => My first blog
            [url] => http://myfirstblog.blogspot.com
        )

    [1] => Array
        (
            [blogid] => 35946977
            [title] => My second blog
            [url] => http://mysecondblog.blogspot.com
        )

    [2] => Array
        (
            [blogid] => 36320167
            [title] => My third blog
            [url] => http://mythirdblog.mysite.com
        )

)

With this informations you can choose which blogs you’d like to add new post, edit post or delete post. To retain compatibility with previous version, you still can use the old methods (if you only have one blog in your Blogger account), only now you can add Blog ID input to choose which blog you’d like to manipulate.

For example, if you want to add new post to my first blog above,

<?php

  require_once "Ngeblog.php";

  $myblog = new Ngeblog("yourusername","yourpassword");

  $title    = 'Ketupat Party';
  $msg      = '<u>Wow</u>, we\'re eating ketupat <i>now</i>?';
  $blogid   = '36455441';

  if ( $myblog->newPost($title,$msg,$blogid) ) {
    echo "Posting success";
  } else {
    echo "Posting failed";
  }

?>

To edit a post with entry id 116155171898341151 in my second blog above,

  $title    = 'New Ketupat Party';
  $msg      = '<u>Wow</u>, we\'re eating ketupat and chicken<i>now</i>?';
  $blogid   = '35946977';
  $entryid  = '116155171898341151';

  if ( $myblog->editPost($entryid,$title,$msg,$blogid) ) {
    echo "Update success";
  } else {
    echo "Update failed";
  }

To get the five of first entries in my third blog, do like this,


  $startindex = 1;
  $maxresults = 5;
  $blogid     = '36320167';
  $myblog->getPosts($startindex,$maxresults,$blogid);

Update yourself

Since i plan to make other improvements to this class, please always update yourself by following this category link in my blog. Or check the newest class here in phpclasses.

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.