PHP code example of copyleaks / php-plagiarism-checker

1. Go to this page and download the library: Download copyleaks/php-plagiarism-checker library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

copyleaks / php-plagiarism-checker example snippets




    opyleaks\Copyleaks;
    use Copyleaks\CopyleaksFileSubmissionModel;
    use Copyleaks\SubmissionProperties;
    use Copyleaks\SubmissionWebhooks;

    // --- Your Credentials ---
    $EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
    $KEY = 'YOUR_API_KEY';
    $WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
    // --------------------

    // Log in to the Copyleaks API
    echo "Authenticating...\n";
    $copyleaks = new Copyleaks();
    $loginToken = $copyleaks->login($EMAIL_ADDRESS, $KEY);
    echo "✅ Logged in successfully!\n";




    opyleaks\Copyleaks;
    use Copyleaks\CopyleaksFileSubmissionModel;
    use Copyleaks\SubmissionProperties;
    use Copyleaks\SubmissionWebhooks;

    // --- Your Credentials ---
    $EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
    $KEY = 'YOUR_API_KEY';
    $WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
    // --------------------

    // Prepare your content for scanning
    echo "Submitting text for scanning...\n";
    $textToScan = "Hello world, this is a test.";
    $base64Content = base64_encode($textToScan);
    $scanId = time();

    // Configure the scan
    $webhooks = new SubmissionWebhooks($WEBHOOK_URL);
    $properties = new SubmissionProperties($webhooks);
    $properties->setSandbox(true); // Turn on sandbox mode for testing

    $submission = new CopyleaksFileSubmissionModel($base64Content, 'test.txt', $properties);

    // Submit the scan to Copyleaks
    $copyleaks->submitFile($loginToken, $scanId, $submission);
    echo "🚀 Scan submitted successfully! Scan ID: " . $scanId . "\n";
    echo "You will be notified via your webhook when the scan is complete.\n";




    opyleaks\Copyleaks;
    use Copyleaks\CopyleaksNaturalLanguageSubmissionModel;

    // --- Your Credentials ---
    $EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
    $KEY = 'YOUR_API_KEY';
    $WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
    // --------------------

    $sampleText = "Lions are social animals, living in groups called prides, typically consisting of several females, their offspring, and a few males. Female lions are the primary hunters, working together to catch prey. Lions are known for their strength, teamwork, and complex social structures.";

    $submission = new CopyleaksNaturalLanguageSubmissionModel(
      $sampleText,
    );
    $submission->sandbox = true;

    $response = $this->copyleaks->aiDetectionClient->submitNaturalLanguage($authToken, time(), $submission);
    $this->logInfo('AI Detection - submitNaturalLanguage', $response);




    opyleaks\Copyleaks;
    use Copyleaks\CopyleaksWritingAssistantSubmissionModel;

    // --- Your Credentials ---
    $EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
    $KEY = 'YOUR_API_KEY';
    $WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
    // --------------------

    $sampleText = "Lions are the only cat that live in groups, called pride. A prides typically consists of a few adult males, several feales, and their offspring. This social structure is essential for hunting and raising young cubs. Female lions, or lionesses are the primary hunters of the prid. They work together in cordinated groups to take down prey usually targeting large herbiores like zbras, wildebeest and buffalo. Their teamwork and strategy during hunts highlight the intelligence and coperation that are key to their survival.";

    $scoreWeights = new ScoreWeights(
      0.1, 0.2, 0.3, 0.4
    );

    $submission = new CopyleaksWritingAssistantSubmissionModel(
      $sampleText,
    );

    $submission->sandbox = true;
    $submission->score = $scoreWeights;

    $response = $this->copyleaks->writingAssistantClient->submitText($authToken, time(), $submission);
    $this->logInfo('Writing Assistant - submitText', $response);




    opyleaks\Copyleaks;
    use Copyleaks\CopyleaksTextModerationRequestModel;

    // --- Your Credentials ---
    $EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
    $KEY = 'YOUR_API_KEY';
    $WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
    // --------------------

    var labelsArray = new CopyleaksTextModerationLabel[]
                    {
                        new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.ADULT_V1),
                        new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.TOXIC_V1),
                        new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.VIOLENT_V1),
                        new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.PROFANITY_V1),
                        new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.SELF_HARM_V1),
                        new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.HARASSMENT_V1),
                        new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.HATE_SPEECH_V1),
                        new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.DRUGS_V1),
                        new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.FIREARMS_V1),
                        new CopyleaksTextModerationLabel(CopyleaksTextModerationConstants.CYBERSECURITY_V1)
                    };

    var model = new CopyleaksTextModerationRequestModel(
                    text: "This is some text to scan.",
                    sandbox: true,
                    language: CopyleaksTextModerationLanguages.ENGLISH,
                    labels: labelsArray
    );

    $response = $this->copyleaks->textModerationClient->submitText($authToken, time(), $model);
    $textModerationResponse= CopyleaksTextModerationResponseModel::fromArray(json_decode(json_encode($response), true));

    $this->logInfo('Text Moderation - submitText', $textModerationResponse);

bash
composer