Ngeblog 0.0.2

What is Ngeblog? A nice guy from phpclasses has made great description for me,

This class can be used to manipulate Blogger blogs using the GData, the Google Data API.

You can download the newest files here. I included some example files there.

There are some dramatic changes i made for this version, including methodes naming and code beautification. Hopefully, with this new codes, it will be easy to extends it in the future.

So, if you happened to use the older version, you should make some changes too. Here are the newest howto’s,

Get an entry

<?php

  require_once "Ngeblog.php";

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

  $entryid = 116086097264268587;  // entry ID you want to get
  $res = $my blog->getPost($entryid);

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

?>

Get list of entries

<?php

  require_once "Ngeblog.php";

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

  $res = $myblog->getPosts(1,5);  // this will get five entries from first index

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

?>

Post a new entry

<?php

  require_once "Ngeblog.php";

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

  $title  = "This is my title";
  $msg    = "<p>This is your <i>content</i></p>";

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

?>

Delete an entry

<?php

  require_once 'Ngeblog.php';

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

  $entryid = '116086019043835900'; // the entry id to be deleted

  if ( $myblog->deletePost($entryid) ) {
    echo "The entry with id $entryid has been deleted";
  }

?>

Update an entry

<?php

  require_once "Ngeblog.php";

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

  $entryid  = "116148936968661097"; // entry ID you want to update
  $newtitle    = "My New Title";
  $newmsg      = "<p>This is your <i>content</i></p>";

  if ( $myblog->editPost($entryid,$newtitle,$newmsg) ) {
    echo "Updating entry $entryid success";
  } else {
    echo "Updating failed";
  }

?>

Leave a comment

Your email address will not be published.

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