WordPressUniversal is a PCL library that aims at simplyfing WordPress based news reader apps. Compatible with WP8&81SL, WP8.1 Runtime, Win81 and Xamarin.iOS as well as Xamarin.Android.
Currently, guest commenting is not supported by Jetpack's JSON API. I already reached out to them and will add this feature as soon as it is available.
To get started, you declare a new WordPressClient:
WordPressClient client = new WordPressClient();
This enables you to use one of the basic methods to fetch the important data from your WordPress site into your app:
get a list of posts:
var postlist= await client.GetPostList("yoursite.com", PostType.post, PostStatus.publish, 10, 0);
This fetches the 10 most recent posts from your WordPress blog.
Pagination is supported by setting the offset:
var postlist_page2 = await client.GetPostList("yoursite.com", PostType.post, PostStatus.publish, 10, 10);
get a list of pages:
var pageslist= await client.GetPostList("yoursite.com", PostType.page, PostStatus.publish, 10, 0);
This fetches 10 pages from your WordPress blog.
Pagination is supported by setting the offset:
var pageslist_page2 = await client.GetPostList("yoursite.com", PostType.page, PostStatus.publish, 10, 10);
get a list of categories:
var categorieslist= await client.GetCategoriesList("yoursite.com");
This fetches 100 categories from your WordPress blog. To change the amount, you can set the optional number parameter (Limit: 1000).
Pagination is supported by setting the offset:
var categorieslist= await client.GetCategoriesList("yoursite.com", 100, 100);
get a list of posts in a category:
var category_postlist= await client.GetCategoryPostList("yoursite.com", "category", PostType.post, PostStatus.publish, 10, 0);
This fetches the 10 most recent posts in a category from your WordPress blog.
Pagination is supported by setting the offset:
var category_postlist_page2 = await client.GetCategoryPostList("yoursite.com", "category", PostType.post, PostStatus.publish, 10, 10);
get a list of most recent comments for your WordPress site:
var recent_commentslist= await wordpressClient.GetCommentsList("yoursite.com", CommentsListType.site, CommentType.comment, CommentStatus.approved);
This fetches the 20 most recent comments from your WordPress blog. To change the amount, your can set the optional number parameter (Limit: 100).
Pagination is supported by setting the offset:
var recent_commentslist_page2= await wordpressClient.GetCommentsList("yoursite.com", CommentsListType.site, CommentType.comment, CommentStatus.approved, null, 20, 20);
get a list of most recent comments for a post
var post_commentslist= await wordpressClient.GetCommentsList("yoursite.com", CommentsListType.post, CommentType.comment, CommentStatus.approved, "post_id");
This fetches the 20 most recent comments of a post from your WordPress blog. To change the amount, your can set the optional number parameter (Limit: 100).
Pagination is supported by setting the offset:
var post_commentslist_page2= await wordpressClient.GetCommentsList("yoursite.com", CommentsListType.site, CommentType.comment, CommentStatus.approved, "post_id", 20, 20);
All requests return objects that you can immediately work with. The library does all the deserialization for you (using JSON.net).
For questions contact me via Twitter: @msicc
planned features:
- load posts based on a category
- search posts/pages/comments
- post comments throuhg the API (as soon as this is technically possible)
- converter for the post/page content (currently a HTML formatted string is returned)