Permalink
Browse files

Update README.md

  • Loading branch information...
Copyleaks committed Dec 28, 2016
1 parent d1fadff commit 042819804951c1c1ba7e1f87f4627fe1b4bc4e2f
Showing with 50 additions and 17 deletions.
  1. +50 −17 README.md
@@ -26,53 +26,84 @@ Install-Package CopyleaksAPI
<p><a href="https://copyleaks.com/Account/Register">Signup</a> to Copyleaks and confirm your account by clicking the link on the confirmation email. Generate your personal API key on your dashboard (<a href="https://api.copyleaks.com/businessesapi">Businesses dashboard/</a><a href="https://api.copyleaks.com/academicapi">Academic dashboard/</a><a href="https://api.copyleaks.com/websitesapi">Websites dashboard</a>) under 'Access Keys'. </p>
<p>For more information check out our <a href="https://api.copyleaks.com/Guides/HowToUse">API guide</a>.</p>
<h3>Example</h3>
<p>This code will show you where the textual content in the parameter ‘url’ has been used online:</p>
<p>This code will show you how to scan files or URLs for plagiarism:</p>
<pre>
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)
private static void Scan(string email, string apiKey)
{
CopyleaksCloud copyleaks = new CopyleaksCloud();
CopyleaksCloud copyleaks = new CopyleaksCloud(eProduct.Businesses);
CopyleaksProcess createdProcess;
ProcessOptions scanOptions = new ProcessOptions()
{
// SandboxMode = true // -------------------> Read more https://api.copyleaks.com/Documentation/RequestHeaders#sandbox-mode
};
ProcessOptions scanOptions = new ProcessOptions();
scanOptions.SandboxMode = true; // Sandbox mode --> Read more https://api.copyleaks.com/GeneralDocumentation/RequestHeaders#sandbox-mode
ResultRecord[] results;
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)
if (!scanOptions.SandboxMode && creditsBalance == 0)
{
Console.WriteLine("ERROR: You do not have enough credits to complete this scan. Your current credit balance is {0}).", creditsBalance);
Console.WriteLine("ERROR: You do not have enough credits to complete this scan. Your balance is {0}).", creditsBalance);
Environment.Exit(2);
}
#endregion
#region callbacks
// Add a URL address to get notified, using callbacks, once the scan results are ready.
//Read more https://api.copyleaks.com/GeneralDocumentation/RequestHeaders#callbacks
//scanOptions.HttpCallback = new Uri("http://callbackurl.com?pid={PID}");
//scanOptions.InProgressResultsCallback = new Uri("http://callbackurl.com?pid={PID}");
#endregion
#region Submitting a new scan process to the server
Console.Write("Creating process...");
createdProcess = copyleaks.CreateByUrl(new Uri(url), scanOptions);
// Insert here the URL that you'd like to scan for plagiarism
createdProcess = copyleaks.CreateByUrl(new Uri("http://urltoscan.com"), scanOptions);
// Insert here the file that you'd like to scan for plagiarism
//createdProcess = copyleaks.CreateByFile(new FileInfo("C:\FiletoScan.pdf"), scanOptions);
Console.WriteLine("Done (PID={0})!", createdProcess.PID);
#endregion
#region Waiting for server's process completion
// Use this if you are not using callback
Console.Write("Scanning... ");
ushort currentProgress;
while (!createdProcess.IsCompleted(out currentProgress))
{
Console.WriteLine(currentProgress + "%");
Thread.Sleep(5000);
}
Console.WriteLine("Done.");
#endregion
#region Processing finished. Getting results
ResultRecord[] results = createdProcess.GetResults();
results = createdProcess.GetResults();
if (results.Length == 0)
{
Console.WriteLine("No results.");
@@ -81,13 +112,15 @@ private static void Scan(string email, string apiKey, string url)
{
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);
Console.WriteLine("Information: {0} copied words ({1}%)", results[i].NumberOfCopiedWords, results[i].Percents);
Console.WriteLine("Comparison report: {0}", results[i].ComparisonReport);
Console.WriteLine("Title: {0}", results[i].Title);
Console.WriteLine("Introduction: {0}", results[i].Introduction);
Console.WriteLine("Embeded comparison: {0}", results[i].EmbededComparison);
}
}
#endregion
}
catch (UnauthorizedAccessException)
@@ -104,7 +137,7 @@ private static void Scan(string email, string apiKey, string url)
Console.WriteLine("*** Error {0}:", theError.CopyleaksErrorCode);
Console.WriteLine("{0}", theError.Message);
}
}
}
</pre>
<h3>Dependencies:</h3>
<ul>

0 comments on commit 0428198

Please sign in to comment.