WordPressHelper
This library is created for get post and information from a blog or a website created with WordPress
Import
At the moment the library is in my personal maven repo
repositories {
maven {
url 'http://dl.bintray.com/raphaelbussa/maven'
}
}
dependencies {
compile 'rebus:wordpress-helper:1.0.10'
}
How to use
How to parse a generic WordPress feed
import rebus.wordpress.helper.FeedItem; import rebus.wordpress.helper.FeedParser; private FeedParser feedParser; feedParser = new FeedParser("feed rss");
//set rss url like http://www.smartphone-italia.com/feed feedParser.showLoading(true, getString(R.string.loading), this);
//set loading dialog, need boolean value, string to show and context feedParser.execute();
//start parsing! feedParser.onFinish(new FeedParser.OnComplete() {
@Override
public void onFinish(ArrayList<FeedItem> feedItems) {
//return arraylist with all info for each item
//do here something when parsing is finished
}
@Override
public void onError() {
//this method is call on parsing error
}
}
);
You can also use StarDataBase class for save article in a database
import rebus.wordpress.helper.StarDataBase; import rebus.wordpress.helper.FeedItem; private StarDataBase starDataBase; private FeedItem feedItem; starDataBase = new StarDataBase(this);
int numStar = getStarCount();
//return number of item in the database boolean isPresent = starDataBase.isStar(feedItem);
//check if the item is in the database, returns true if there is starDataBase.addStar(feedItem);
//add item starDataBase.deleteStar(feedItem);
//delete item starDataBase.deleteAll();
//delate all item form database ArrayList<FeedItem> feedItems = starDataBase.getStar();
//get arraylist with all item
Get comments from an article
import rebus.wordpress.helper.CommentItem; import rebus.wordpress.helper.CommentParser; private CommentParser commentParser; commentParser = new CommentParser("comments feed rss");
//you can get this value from precedent parsing using feedParser.getCommentRss();
commentParser.execute();
//start parsing! commentParser.onFinish(new CommentParser.OnComplete() {
@Override
public void onFinish(ArrayList<CommentItem> commentItems) {
//return arraylist with all info for each comment
//do here something when parsing is finished
}
@Override
public void onError() {
//this method is call on parsing error
}
}
);
If the blog use default WordPress comment system you can use PostComment class for add a comment
import rebus.wordpress.helper.PostComment; PostComment postComment = new PostComment(
"id post", //you can get this value from precedent parsing using feedParser.getId();
"http://www.smartphone-italia.com", //base url of blog
"name user", //name of the commenter required
"email user", //email of the commenter required
"web site user", //web site of the commenter not required, you can pass an empty string
"body of comment", //body of comment required
"0");
//if is a new comment you must pass a string with value "0", if is an answer you must pass the id of the comment to which you want to respond, you can get this value from precedent parsing commentItem.getId();
postComment.showLoading(true, getString(R.string.loading), this);
//set loading dialog, need boolean value, string to show and context postComment.execute();
//send comment! postComment.onFinish(new PostComment.OnComplete() {
@Override
public void onFinish() {
//this method is call on sending comment successful
}
@Override
public void onError() {
//this method is call on sending comment error
}
}
);
You can also get post from a specific author using AuthorParser
import rebus.wordpress.helper.AuthorParser; import rebus.wordpress.helper.FeedItem; private AuthorParser authorParser; authorParser = new AuthorParser("http://www.smartphone-italia.com", "rebus");
//set url of blog and author nickname authorParser.showLoading(true, getString(R.string.loading), this);
//set loading dialog, need boolean value, string to show and context authorParser.execute();
//start parsing! authorParser.onFinish(new AuthorParser.OnComplete() {
@Override
public void onFinish(ArrayList<FeedItem> feedItems) {
//return arraylist with all info for each item
//do here something when parsing is finished
}
@Override
public void onError() {
//this method is call on parsing error
}
}
);
And in the end you can search in the blog
import rebus.wordpress.helper.SearchParser; import rebus.wordpress.helper.FeedItem; private SearchParser searchParser; searchParser = new SearchParser("http://www.smartphone-italia.com", "search something");
//set url of blog and search query searchParser.showLoading(true, getString(R.string.loading), this);
//set loading dialog, need boolean value, string to show and context searchParser.execute();
//start parsing! searchParser.onFinish(new SearchParser.OnComplete() {
@Override
public void onFinish(ArrayList<FeedItem> feedItems) {
//return arraylist with all info for each item
//do here something when parsing is finished
}
@Override
public void onError() {
//this method is call on parsing error
}
}
);
Remember if you use loading dialog
@Override protected void onPause() {
super.onPause();
feedParser.onPauseLoading();
}
Changelog
- 1.0.8 fix category/tag bug
- 1.0.7 fix bintray maven upload
- 1.0.6 bug fix
- 1.0.5 bug fix
- 1.0.4 bug fix
- 1.0.3 bug fix
- 1.0.2 bug fix
- 1.0.1 bug fix
- 1.0.0 add StarDatabase
- 0.0.1 first alpha
App using WordPress Helper
If you use this lib [contact me](mailto: [email protected]?subject=WordPress Helper) and I will add it to the list below:
###Developed By Raphaël Bussa - [email protected]
License
The MIT License (MIT) Copyright (c) 2015 Raphael Bussa <[email protected]> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.