Copyleaks SDK is a simple framework that allows you to perform plagiarism scans and track content distribution around the web, using the Copyleaks cloud.
With the Copyleaks SDK you can submit a scan for:
- Webpages
- Local files - pdf, doc, docx, rtf and more (see full list)
- Free text
- OCR (Optical Character Recognition) - scanning pictures containing textual content (see full list)
You can integrate with the Copyleaks SDK in one of two ways:
- Download the code to your workspace – choose this option if you want to alter the code and add capabilities to match your own specific needs. Download the project from here, open it using Eclipse and choose ‘Import Project’ from your own workspace. Then, follow the next steps:
- Go to ‘General’, choose ‘Existing projects into workspace’ and press next.
- Fill in the details about the project you just downloaded under ‘Select root directory’.
- Make sure that the project Copyleaks API is checked.
- Press ‘Finish’.
Now you have the project in your workspace and you can make alterations that fits your own specific needs. As default, the project includes the file ‘Main.java’. This file will allow you to easily run and check your project.
- Download the JAR files – choose this option if you want to use the code as-is. Download the JAR files and then, follow the next steps:
- Extract the files.
- Open Eclipse and select the process you want to integrate with Copyleaks API.
- Press the right mouse key and choose ‘Build Path’ -> ‘Configure Build Path’.
- In the window that opened choose the tab ‘Libraries’.
- Press on ‘Add External JAR’.
- Browse the libraries with your extracted JAR files and choose to add them.
Now you can use the Copyleaks API in your project. If you are working with our latest version, you can also run the libraries using the code found down on this page.
To use Copyleaks API you need to be a registered user. Signing up is quick and free of charge.
Signup to Copyleaks and confirm your account by clicking the link in the confirmation email. Generate your personal API key on your dashboard (Businesses dashboard/Academic dashboard/Websites dashboard) under 'Access Keys'.
For more information check out our API guide.
This code will show you where the textual content in the parameter ‘url’ has been used online:
public static void Scan(String email, String key, String url) {
CopyleaksCloud copyleaks = new CopyleaksCloud();
try {
System.out.print("Login to Copyleaks cloud...");
copyleaks.Login(email, key);
System.out.println("Done!");
System.out.print("Checking account balance...");
int creditsBalance = copyleaks.getCredits();
System.out.println("Done (" + creditsBalance + " credits)!");
if (creditsBalance == 0) {
System.out.println(
"ERROR: You do not have enough credits left in your account to proceed with this scan! (current credit balance = "+ creditsBalance + ")");
return;
}
ProcessOptions scanOptions = new ProcessOptions();
// scanOptions.setSandboxMode(true); // <------ Read more @
// https://api.copyleaks.com/Documentation/RequestHeaders#sandbox-mode
ResultRecord[] results;
CopyleaksProcess createdProcess;
createdProcess = copyleaks.CreateByUrl(new URI(url), scanOptions);
// Waiting for process completion...
System.out.println("Scanning...");
int percents = 0;
while (percents != 100 && (percents = createdProcess.getCurrentProgress()) <= 100) {
System.out.println(percents + "%");
if (percents != 100)
Thread.sleep(4000);
}
results = createdProcess.GetResults();
if (results.length == 0) {
System.out.println("No results.");
} else {
for (int i = 0; i < results.length; ++i) {
System.out.println();
System.out.println(String.format("Result %1$s:", i + 1));
System.out.println(String.format("Url: %1$s", results[i].getURL()));
System.out.println(String.format("Percents: %1$s", results[i].getPercents()));
System.out.println(String.format("CopiedWords: %1$s", results[i].getNumberOfCopiedWords()));
}
}
} catch (CommandFailedException copyleaksException) {
System.out.println("Failed!");
System.out.format("*** Error (%d):\n", copyleaksException.getCopyleaksErrorCode());
System.out.println(copyleaksException.getMessage());
} catch (Exception ex) {
System.out.println("Failed!");
System.out.println("Unhandled Exception");
System.out.println(ex);
}
}