DisqusSDK-Android


Source link: https://github.com/jjhesk/DisqusSDK-Android

DisqusSDK-Android

This is the simple library for https://disqus.com/ developed on Android.

About

This library implements the Disqus API for use in Android applications. This librar is ongoing

Gradle settings

repositories {

 maven {
 url 'https://dl.bintray.com/jjhesk/maven' 
}
 
}
 dependencies {

 compile 'DisqusSDK-Android:disqus:0.2.7' 
}

API RoadMap Support

  • Post comments
  • Post Comments more flexible
  • Updated authentication OAuth2.0 standard
  • Additional support for the CacheUrl mechanism
  • enable extending from fragment. PostCommentFragment
  • setup the activity for login
  • construct the configuration object

Installation

  • enable extending from fragment. PostCommentFragment
  • setup the activity for login
  • construct the configuration object

Using AuthorizeActivity

  1. Use AuthorizeUtils.createIntent to create a new Intent with your application settings.
  2. Start the activity with startActivityForResult.
  3. Implement 'onActivityResult' to get the access token object:
 @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

// Check which request we're responding to

if (requestCode == DisqusClient.authorization_intent_id) {

 // Make sure the request was successful

 if (resultCode == RESULT_CANCELED) {

  Toast.makeText(this, getResources().getString(com.hkm.disqus.R.string.failurelogin), Toast.LENGTH_LONG);

 
}

 if (resultCode == RESULT_OK) {

  AccessToken token = (AccessToken) data.getExtras().getParcelable(AuthorizeActivity.EXTRA_ACCESS_TOKEN);

  addLine(token.accessToken);

  release_pending_content();

 
}

}

  
}

 protect void release_pending_content(){

  if (appending_post_content != null) {

 postPost(appending_post_content, post_post_id);

 appending_post_content = null;

}

  
}
 
  1. ApiConfiguration Object Sample: The forum name will be used as the following reference:

" https://disqus.com/api/3.0/threads/set.json?forum=\(forumShortName)&api_key=\(apiKey)&thread=ident:\(postID)%20\(domain)/?p=\(postID)"

public class DqUtil {

  public static ApiConfig genConfig() {

ApiConfig conf = new ApiConfig(

  BuildConfig.DISQUS_API_KEY,

  BuildConfig.DISQUS_DEFAULT_ACCESS,

  RestAdapter.LogLevel.BASIC);

 conf

 .setForumName("__forum_name__")

 .setApiSecret(BuildConfig.DISQUS_SECRET)

 .setRedirectUri(BuildConfig.DISQUS_REDIRECT_URI);

  return conf;
  
}
 
}

Standard options

  • API key - mandatory for all requests.
  • Access token - required for requests that require authentication.
  • Referrer - required for some requests that perform domain checks, should match a domain in your Disqus app settings.
  • Log level - set the Retrofit logging level, see Square's docs for details.

Other options

  • API secret - intended for server to server requests as an alternative to the API key/access token and provided for completeness. Can be used from a mobile app but this presents security risks and is not recommended.

Create client

As of version 0.9.0 the library is using Retrofit for requests.

The ApiClient can be used to create Disqus resource objects based on the Retrofit interfaces defined in the me.philio.disqus.api.resources package. It works as a wrapper to the Retrofit RestAdapter and configures the adapter and deserialisation options for Gson.

 ApiClient apiClient = new ApiClient(apiConfig);

Create resource and make requests

 Applications applications = apiClient.createApplications();

  Response<Usage> usage = applications.listUsage("MyApp", 7);

All resources and requests match the naming conventions defined in the Disqus API documentation, but often method signatures are kept as simple as possible.

Advance Sample Code

  setup.createThreads().listPostByIDAsync(comment_id, "hypebeast", cb);

private void getPost() {

try {

 base.getComments("1008680 http://hypebeast.com/?p=1008680", new Callback<com.hkm.disqus.api.model.Response<List<Post>>>() {

  @Override

  public void success(com.hkm.disqus.api.model.Response<List<Post>> posts, Response response) {

 com.hkm.disqus.api.model.Response<List<Post>> d = posts;

 Log.d(TAG, "now its working now");

  
}

@Override

  public void failure(RetrofitError error) {

Log.d(TAG, error.getMessage());

  
}

 
}
);

}
 catch (ApiException e) {

 
}

  
}
 

In general:

  • Named parameters are required and should not be null.

  • Optional parameters can be provided as a Map where applicable, refer to the Disqus documentation for details of optional parameters.

Response format

All requests will return a Response object. Typical responses contain an error code (which will always be 0 as errors throw exceptions), an optional cursor (which can be used for pagination) and some data which is a generic type.

The data is usually an object or list of objects and for the majority of requests will be one of the models defined in the API package. Some requests return empty structures so to avoid parsing issues the data type is either Object or List<Object>, the response data for these requests can be disregarded.

Known issues

Disqus issues

  1. The cancel button for the authorisation page doesn't work.
  2. Related param has no effect when used with Blacklists.list() method.
  3. update after post thread doesnt work.

Resources

Transform images into pixel versions of itself in Android.

Simple and effective bug reporting tool for Android apps.

AssertJ assertions for RxJava Observables.

This library extends AssertJ core with the aim of providing elegant assertions to test RxJava Observables. The current version of this library only provides assertions aimed at testing "cold" Observables. You will need to transform your Observable into a BlockingObservable before performing any assertion.

A library for testing javac compilation with or without annotation processors.

Android library which allows you to swipe down from an activity to close it.

IntelliJ plugin for adding Fragment newInstance Inspection.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes