Pages

Tuesday, May 6, 2014

The FORUMS libre SDK

The FORUMS libre SDK is a Software Development Kit that makes it simple to add forums to your own mobile application or website.

The SDK currently provides two components. The first is a Java Connection API that makes it easy to access FORUMS libre from a Java environment such as Android, or a Java web server. The second component is a set of Android activities that you can add to your own Android app, or copy/customize in your own app.

The SDK is developed under Project Libre an open source project hosted on GitHub
https://github.com/paphus/Project-Libre

Connection API

You can create a connection to the FORUMS libre server using the SDKConnection class. You need to pass your connection Credentials, which includes your application ID. You can obtain an application from the FORUMS libre website, from your user details page.

SDKConnection connection =
        new SDKConnection(new FORUMSlibreCredential("12345");

The SDK includes a set of data objects that represent the FORUMS libre object model.
The data objects are in the com.paphus.sdk.config package, and include the following,

  • UserConfig - Defines a user's credentials and info.
  • ForumConfig - Defines a forum's details.
  • ForumPostConfig - Defines a forum post.
  • BrowseConfig - Defines a search query criteria.
  • ChannelConfig - Defines a live chat channel's details.
  • InstanceConfig - Defines a bot's details.
  • DomainConfig - Defines a domain's details.
  • ChatConfig - Input for chat bot messaging.
  • VoiceConfig - Defines a chat bot's voice.
  • ChatResponse - Response for chat bot messaging.
  • ContentConfig - Defines a tag/category request.

Users

The API allows you to connect a user, or create a new user.

Use the connect() API to connect a user, the user's details will be returned, or an error message if the connect fails. The returned user details will not include the password, but will include a token, that can be used in place of the password. After connecting a connection, all subsequent requests will use the user credentials, until you call disconnect().

UserConfig user = new UserConfig();
user.user = "test";
user.password = "password";
user = connection.connect(user);

Use the create() API to create a new user. A user id and password are required. You can also pass the user's name, email, bio, and other details. The user details are returned, with a token in place of the password.

UserConfig user = new UserConfig();
user.user = "test";
user.password = "password";
user.name = "Test Account";
user.email = "test@test.com";
user = connection.create(user);

Forums

The API allows you to browse forums, forums posts, and create forum posts and replies.

The browse() API is used to browse or search the set of forums in the domain.

BrowseConfig browse = new BrowseConfig();
browse.type = "Forum";
browse.typeFilter= "Public";
browse.tag= "cool";
browse.sort = "name";
List forums = connection.browse(browse);

The getPosts() API is used to browse or search a forum's posts.

BrowseConfig browse = new BrowseConfig();
browse.typeFilter = "Public";
browse.tag= "cool";
browse.sort = "date";
List posts = connection.getPosts(browse);

The fetch() API is used to get a forum's, or forum post's details.

ForumConfig forum = new ForumConfig();
forum.id = "12345";
forum = connection.fetch(forum);
ForumPostConfig post = new ForumPostConfig();
post.id = "12345";
post = connection.fetch(post);

The create() API is used to create a new forum post. You must set the post's forum's id, and the post's details will be returned, including its id.

ForumPostConfig post = new ForumPostConfig();
post.forum = "12345";
post.topic = "Party tonight";
post.details = "Party at Rick's place tonight.";
post.tags = "party";
post = connection.create(post);

The createReply() API is used to create a new forum post reply. You must set the post's id you are replying to, and the reply's details will be returned, including its id.

ForumPostConfig reply = new ForumPostConfig();
reply.parent = "12345";
reply.details = "I'll be there.";
post = connection.createReply(post);

Android Activities

The SDK includes a set of Android activities you can reuse, or modify in your own app. The MainActivity contains the SDKConnection and some shared data, so you will need to include it even if not using the activity. The forums activities include, BrowsePostsActivity, ChooseForumActivity, ChoosePostActivity, CreateForumPostActivity, CreateReplyActivity, EditForumPostActivity, ForumActivity, ForumBrowseActivity, and ForumPostActivity.

Here is an example of launching a ForumActivity.

MainActivity.current = new MainActivity();
ForumConfig config = new ForumConfig();
config.id = "12345";
HttpAction action = new HttpFetchAction(this, config);
action.execute();

Note, because of the way Android does its packaging, you will need to search/replace the "com.paphus.sdk.activity.R" import with your own application's unique package. This will resolve the generated R class dependencies.

You can use the SDK to access any of FORUMS libre's services, for personal, academic, or commercial applications. You cannot use them for spam, or to violate the FORUMS libre terms of service. FORUMS libre's services are also provided as a commercial service on Paphus Live Chat.

Monday, May 5, 2014

The FORUMS libre web API

In addition to being able to embed your forum on your own website, and access them from any Android device, you can also access your forums through the FORUMS libre web API. The web API gives you the advantage of having complete control of your forum's client interface.

You can use the web API to access your forum from your own website through JavaScript, PHP or any other language. You can also use the web API to create your own mobile application to access your forum, such as an Android or iOS application.

A web API, is a set of HTTP GET/POST URI's that allow sending and receiving of message data. When you browse a website, your browser makes a series of HTTP GET/POST requests to URIs that return HTML content. In a web service the URIs return XML or JSON data, instead of HTML content.

The FORUMS libre web API provides a REST API with XML message content. The API takes HTTP POST XML data, and returns XML data.

HTTP XML POST API

  • http://www.forumslibre.com/rest/forumslibre/create-user
  • http://www.forumslibre.com/rest/forumslibre/check-user
  • http://www.forumslibre.com/rest/forumslibre/get-forums
  • http://www.forumslibre.com/rest/forumslibre/get-forum-posts
  • http://www.forumslibre.com/rest/forumslibre/check-forum
  • http://www.forumslibre.com/rest/forumslibre/check-forum-post
  • http://www.forumslibre.com/rest/forumslibre/create-forum-post
  • http://www.forumslibre.com/rest/forumslibre/create-reply
  • http://www.forumslibre.com/rest/forumslibre/update-forum-post

create-user

The create-user API creates a new user, and returns the user's details.

URI: http://www.forumslibre.com/rest/forumslibre/create-user
Parameters: application, user, password, hint, name, showName, email, website, bio

XML POST Example

check-user

The check-user API validates a user, and returns the user's details.

URI: http://www.forumslibre.com/rest/forumslibre/check-user
Parameters: application, user, password, token

Parameters

applicationREQUIRED: The application ID.
userREQUIRED: The ID of the user.
passwordREQUIRED: The password of the user. A token can also be used.
tokenREQUIRED: The token of the user. A token can be obtained through check-user, and is valid until reset.

XML POST Example

get-forums

The get-forums API queries the details for all forums matching the criteria.

URI: http://www.forumslibre.com/rest/forumslibre/get-forums
Parameters: application, user, password, token, type, tag, category, sort, typeFilter, filter.

XML POST Example

get-forum-posts

The get-forum-posts API queries the details for all forum posts matching the criteria.

URI: http://www.forumslibre.com/rest/forumslibre/get-forum-posts
Parameters: application, user, password, instance, token, type, tag, category, sort, typeFilter, filter.

XML POST Example

check-forum

The check-forum API validates that a forum ID or name exists, and returns the forum's details.

URI: http://www.forumslibre.com/rest/forumslibre/check-forum
Parameters: application, user, password, token, id, name

Parameters

applicationREQUIRED: The application ID.
userOPTIONAL: The ID of the user. The user must be registered with FORUMS libre. If not passed the user will be anonymous. The user is required if the forum is private.
passwordOPTIONAL: The password of the user. A token can also be used.
tokenOPTIONAL: The token of the user. A token can be obtained through check-user, and is valid until reset.
idREQUIRED: The ID of the forum to validate. The forum's name can also be used, but the ID is better as it is guaranteed to be unique.
nameREQUIRED: The name of the forum to validate. The forum's ID can also be used.

XML POST Example

check-forum-post

The check-forum-post API validates that a forum post ID exists, and returns the forum post's details.

URI: http://www.forumslibre.com/rest/forumslibre/check-forum-post
Parameters: application, user, password, token, id

XML POST Example

create-forum-post

The create-forum-post API creates a new forum post, the post details with its ID is returned. You must pass the ID of the forum posting to.

URI: http://www.forumslibre.com/rest/forumslibre/create-forum-post
Parameters: application, user, password, token, forum, topic, details, tags

XML POST Example

create-reply

The create-reply API creates a new forum reply, the reply details with its ID is returned. You must pass the ID of the forum post replying to.

URI: http://www.forumslibre.com/rest/forumslibre/create-reply
Parameters: application, user, password, token, parent, details

XML POST Example

update-forum-post

The update-forum-post API updates a existing forum post, the post details with its ID is returned. You must pass the ID of the forum post you are updating.

URI: http://www.forumslibre.com/rest/forumslibre/update-forum-post
Parameters: application, user, password, token, id, topic, details, tags

XML POST Example

So, that is the basic web API. You can now build your own interface for your forum. You can use the API on your own website, or in your own mobile application.

FORUMS libre now on Android

You can now create, access, and post to forums from your Android phone or device.

The FORUMS libre! app can be downloaded from Google Play, here, or search for forumslibre on Google Play from your Android phone or device.

Sign In

Sign In, or browse forums anonymously. Your sign in is remembered until you sign out, so you only need to sign in once.

Browse

Browse public forums, or your own personal forums. Browse allows filtering and sorting of forums, and remembers the last bot you accessed.

Post

View, reply, and post to forums directly from your phone or device.

Live Chat, Bots, and Domains

The FORUMS libre app also provides live chat, chatrooms, chat bots, and lets you create your own personal domain.
You can also access any forum your create from the Android app from the web interface. The web interface allows additional administrative features for configuring your forum.

Friday, May 2, 2014

Embedding your forum on your own website or blog

You are free to embed the forums your create on your own website or blog. It is quite easy to embed a forum, and only takes a few lines of HTML code. You can embed a forum to provide help or service for your website, or to connect with people on your blog.

The embedding HTML code can be copied from your forum's Embed page under Admin.

The simplest solution is to embed a forum inside your webpage using an iframe. Here is some simple code to embed the FORUMS libre forum in an iframe.

Code to embed a forum in a iframe

This code will produce the following:

The embed tab provides 5 different embedding options. You just need to select the embed option and click "Get Code" to see the results. You can also make up your own option using your own code, or modifying the generated code.

Another option is to put a button or link on your website that open the forum in another window. This can be done using a little Java Script code.

Code to popup a forum in window

This code will produce the following:

So that's it, you should now be able to embed your forum on your website or blog.