Thursday, February 24, 2011

Add labels to Google blogger by API

PHP:
http://gdatatips.blogspot.com/2008/07/labeling-blogger-posts.html

$label1 = new Zend_Gdata_App_Extension_Category(
'foo', 'http://www.blogger.com/atom/ns#');
$label2 = new Zend_Gdata_App_Extension_Category(
'bar', 'http://www.blogger.com/atom/ns#');
$entry->setCategory(array($label1, $label2));

Java:
http://www.one-minute-info.com/2010/06/add-label-to-posts-via-java-blogger-api.html

myEntry = new Entry();
myEntry.setTitle(new PlainTextConstruct("some title"));
myEntry.setContent(new HtmlTextConstruct("some HTML body"));

categories=myEntry.getCategories();

category= new Category();
category.setTerm("whatever label you like such as Google Blogger or Java API");
category.setLabel(null);
category.setScheme("http://www.blogger.com/atom/ns#");
category.setLabelLang(null);

categories.add(category);

URL postUrl = new URL("http://www.blogger.com/feeds/123456/posts/default");
myService.insert(postUrl, myEntry);

2 comments:

Dan Regaz said...
This comment has been removed by the author.
Dan Regaz said...

Very Useful!
Many Thanks :)