The FastComments Java Core package provides the foundational components for integrating FastComments functionality into Java applications and Android applications. This package contains the core models, configurations, and utilities required to work with the FastComments platform.
The core package serves as the base for FastComments Java implementations, providing:
- Comment widget configuration
- SSO (Single Sign-On) implementation
- Callback interfaces for events
- Core models for data representation
Add the Repsy repository to your project's POM:
<repositories>
<repository>
<id>repsy</id>
<name>FastComments Maven Repository on Repsy</name>
<url>https://repo.repsy.io/mvn/winrid/fastcomments</url>
</repository>
</repositories>Then add the dependency:
<dependency>
<groupId>com.fastcomments</groupId>
<artifactId>core</artifactId>
<version>0.0.2</version>
</dependency>Add the Repsy repository to your build.gradle file:
repositories {
mavenCentral()
maven {
url "https://repo.repsy.io/mvn/winrid/fastcomments"
}
}Then add the dependency:
implementation 'com.fastcomments:core:0.0.2'The CommentWidgetConfig class provides configuration options for the FastComments widget. It includes settings for:
- Tenant identification
- Page/URL configuration
- UI customization
- Feature toggles
- Authentication settings
- Callback registration
Example usage:
CommentWidgetConfig config = new CommentWidgetConfig("your-tenant-id", "page-url-id",
"https://example.com/article",
"example.com",
"Article Title");
// Configure additional options
config.showLiveRightAway = true;The core package provides SSO (Single Sign-On) support through the following classes:
FastCommentsSSO: Main class for SSO configurationSecureSSOPayload: For secure SSO implementationSecureSSOUserData: User data for secure SSOSimpleSSOUserData: Simplified user data for basic SSO
// ---- BEGIN SERVER SIDE
SecureSSOUserData userData = new SecureSSOUserData("user-123", "user@example.com", "Example User", "https://example.com/avatar.jpg");
// Create SSO configuration
FastCommentsSSO sso = FastCommentsSSO.createSecure(myApiKey, userData);
String ssoString = sso.prepareToSend(); // send to client
// ---- END SERVER SIDE// ... create user data for SSO (server side!)
// then call the comments api with it
publicApi.getComments(config.tenantId, config.urlId).sso(ssoString)
// ... or add to the widget config for the Android SDK
config.sso = ssoString;// Create user data for SSO (usually client side, less secure)
SimpleSSOUserData userData = new SimpleSSOUserData("ExampleUser", "user@example.com", "https://example.com/avatar.jpg");
// Create SSO configuration
FastCommentsSSO sso = new FastCommentsSSO(userData);
// then call the comments api with it
publicApi.getComments(config.tenantId, config.urlId).sso(sso.createToken())
// ... or add to the widget config for the Android SDK
config.sso = sso.createToken();The core package includes several callback interfaces for handling events:
CommentFlaggedCallback: Called when a comment is flaggedCommentSubmitStartCallback: Called when a comment submission startsInstanceCallback: Generic instance callbackOpenProfileCallback: Called when a user profile should be openedUserBlockedCallback: Called when a user is blockedVoteSuccessCallback: Called when a vote is successful
The core package is designed to work seamlessly with the FastComments Android SDK, providing the foundation for Android applications that want to integrate FastComments functionality.
- Java 8 or higher