Skip to content

Copyleaks is an online plagiarism detector. Use Copyleaks to find out who used your online content. This example shows how to integrate with the Copyleaks cloud, using .Net, to detect copyright infringement.

Mano-S/.NET-Plagiarism-Checker

 
 

Repository files navigation

Copyleaks SDK

Copyleaks SDK is a simple framework that allows you to perform plagiarism scans and track content distribution around the web, using Copyleaks cloud.

With Copyleaks SDK you can submit for scan:

Instructions for using the SDK are below. For a quick example demonstrating the SDK capabilities just look at the code examples under “examples”.

Integration

You can integrate with the Copyleaks SDK in one of two ways:

  1. Download the code from here, compile it and add reference to the assembly.
  2. Add CopyleaksAPI NuGet by running the following command in the Package Manager Console
  3. Install-Package CopyleaksAPI
    

Signing Up and Getting Your API Key

To use the 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 on the confirmation email. Generate your personal API key on your dashboard under 'Access Keys'.

For more information check out our API guide.

Example

This code will show you where the textual content in the parameter ‘url’ has been used online:

using System;
using System.Threading;
using Copyleaks.SDK.API;
using Copyleaks.SDK.API.Exceptions;
using Copyleaks.SDK.API.Models;
//...
private static void Scan(string email, string apiKey, string url)
{
	CopyleaksCloud copyleaks = new CopyleaksCloud();
	CopyleaksProcess createdProcess;
	ProcessOptions scanOptions = new ProcessOptions()
	{
		// SandboxMode = true // -------------------> Read more https://api.copyleaks.com/Documentation/RequestHeaders#sandbox-mode
	};
	try
	{
		#region Login to Copyleaks cloud
		Console.Write("Login to Copyleaks cloud...");
		copyleaks.Login(email, apiKey);
		Console.WriteLine("Done!");
		#endregion
		#region Checking account balance
		Console.Write("Checking account balance...");
		uint creditsBalance = copyleaks.Credits;
		Console.WriteLine("Done ({0} credits)!", creditsBalance);
		if (creditsBalance == 0)
		{
			Console.WriteLine("ERROR: You do not have enough credits to complete this scan. Your current credit balance is {0}).", creditsBalance);
			Environment.Exit(2);
		}
		#endregion
		#region Submitting a new scan process to the server
		Console.Write("Creating process...");
		createdProcess = copyleaks.CreateByUrl(new Uri(url), scanOptions);
		Console.WriteLine("Done (PID={0})!", createdProcess.PID);
		#endregion
		#region Waiting for server's process completion
		Console.Write("Scanning... ");
		ushort currentProgress;
		while (!createdProcess.IsCompleted(out currentProgress))
			Thread.Sleep(5000);
		Console.WriteLine("Done.");
		#endregion
		#region Processing finished. Getting results
		ResultRecord[] results = createdProcess.GetResults();
		if (results.Length == 0)
		{
			Console.WriteLine("No results.");
		}
		else
		{
			for (int i = 0; i < results.Length; ++i)
			{
				Console.WriteLine();
				Console.WriteLine("Result {0}:", i + 1);
				Console.WriteLine("Url: {0}", results[i].URL);
				Console.WriteLine("Percents: {0}", results[i].Percents);
				Console.WriteLine("CopiedWords: {0}", results[i].NumberOfCopiedWords);
			}
		}
		#endregion
	}
	catch (UnauthorizedAccessException)
	{
		Console.WriteLine("Failed!");
		Console.WriteLine("Authentication with the server failed!");
		Console.WriteLine("Possible reasons:");
		Console.WriteLine("* You did not log in to Copyleaks cloud");
		Console.WriteLine("* Your login token has expired");
	}
	catch (CommandFailedException theError)
	{
		Console.WriteLine("Failed!");
		Console.WriteLine("*** Error {0}:", theError.CopyleaksErrorCode);
		Console.WriteLine("{0}", theError.Message);
	}
}                

Dependencies:

Referenced Assemblies:

Read More

About

Copyleaks is an online plagiarism detector. Use Copyleaks to find out who used your online content. This example shows how to integrate with the Copyleaks cloud, using .Net, to detect copyright infringement.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.9%
  • PowerShell 0.1%