Skip to content

Instantly share code, notes, and snippets.

@horte
Last active October 12, 2015 05:38
Show Gist options
  • Save horte/3979503 to your computer and use it in GitHub Desktop.
Save horte/3979503 to your computer and use it in GitHub Desktop.
Custom JSON - publisher.relatedTexts example
JSONObject params = new JSONObject();
params.put("collection_id", collection.getId());
params.put("text_id", articleId);
params.put("collection_scope", (new JSONArray()));
params.put("wait", 50);
params.put("limit", 50);
params.put("days_old", 14);
params.put("allow_later_texts", true);
params.put("tags_skip_tag_related", true);
params.put("tags_min_common_tags", 2);
params.put("tags_include_categories", (new JSONArray()));
params.put("sem_skip_tag_related", false);
params.put("sem_min_common_tags", 2);
params.put("sem_max_threshold", 0.85);
params.put("sem_min_threshold", 0.60);
JSONRPCRequestObject request = new JSONRPCRequestObject(0, "publisher.relatedTexts", params);
try {
JSONRPCResponseObject response = saploAPI.getClient()
.sendAndReceive(request);
JSONObject result = (JSONObject) saploAPI.getClient()
.parseResponse(response);
for (int i = 0; i < result.getJSONArray("related_texts").length(); i++) {
JSONObject jsonObj = result.getJSONArray("related_texts")
.getJSONObject(i);
//Parse related articles
}
} catch (SaploClientException e) {
//Some error occurred. Check error code and handle it...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment