Skip to content

Commit 10a52e8

Browse files
Update README.md
update readme file
1 parent 5d67790 commit 10a52e8

File tree

1 file changed

+197
-31
lines changed

1 file changed

+197
-31
lines changed

README.md

Lines changed: 197 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,215 @@
1-
# Copyleaks PHP SDK
1+
# Copyleaks SDK
2+
The official [Copyleaks](https://copyleaks.com/) PHP library, supporting PHP versions >=7.4.0.
23

3-
Copyleaks SDK is a simple framework that allows you to scan text for plagiarism and detect content distribution online, using the Copyleaks plagiarism checker cloud.
4+
## 🚀 Getting Started
5+
Before you start, ensure you have the following:
46

5-
Using Copyleaks SDK you can check for plagiarism in:
6-
* Online content and webpages
7-
* Local and cloud files (see [supported files](https://api.copyleaks.com/documentation/specifications#2-supported-file-types))
8-
* Free text
9-
* OCR (Optical Character Recognition) - scanning pictures with textual content (see [supported files](https://api.copyleaks.com/documentation/specifications#6-supported-image-types-ocr))
7+
* An active Copyleaks account. If you don’t have one, [sign up for free](https://copyleaks.com/signup).
8+
* You can find your API key on the [API Dashboard](https://api.copyleaks.com/dashboard).
109

11-
## Installation
10+
Once you have your account and API key:
1211

13-
Install using [Packagist](https://packagist.org/packages/copyleaks/php-plagiarism-checker)
12+
**Install the SDK**:
1413

14+
Install using [Packagist](https://packagist.org/packages/copyleaks/php-plagiarism-checker)
1515
```bash
1616
composer require copyleaks/php-plagiarism-checker
1717
```
1818

19-
## Register and Get Your API Key
20-
To use the Copyleaks API you need to first be a registered user. The registration to Copyleaks takes a minute and is free of charge. [Signup](https://api.copyleaks.com/?register=true) and make sure to confirm your account.
19+
## 📚 Documentation
20+
To learn more about how to use Copyleaks API please check out our [Documentation](https://docs.copyleaks.com/resources/sdks/php/).
2121

22-
As a signed user you can generate your personal API key. Do so on your [dashboard home](https://api.copyleaks.com/dashboard) under 'API Access Credentials'.
22+
## 💡 Usage Examples
23+
Here are some common usage examples for the Copyleaks SDK. You can also see a comprehensive code example in the `demo.php` file on our GitHub repository: [demo.php](https://github.com/Copyleaks/PHP-Plagiarism-Checker/blob/master/demo/demo.php).
2324

24-
For more information check out our [API guide](https://api.copyleaks.com/documentation/v3).
25+
### Get Authentication Token
26+
This example demonstrates how to log in to the Copyleaks API and obtain an authentication token.
2527

26-
## Usage
2728
```php
28-
include_once('vendor/copyleaks/php-plagiarism-checker/autoload.php');
29-
use Copyleaks\Copyleaks;
29+
<?php
30+
31+
require_once(__DIR__ . '/vendor/autoload.php');
32+
33+
use Copyleaks\Copyleaks;
34+
use Copyleaks\CopyleaksFileSubmissionModel;
35+
use Copyleaks\SubmissionProperties;
36+
use Copyleaks\SubmissionWebhooks;
37+
38+
// --- Your Credentials ---
39+
$EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
40+
$KEY = 'YOUR_API_KEY';
41+
$WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
42+
// --------------------
43+
44+
// Log in to the Copyleaks API
45+
echo "Authenticating...\n";
46+
$copyleaks = new Copyleaks();
47+
$loginToken = $copyleaks->login($EMAIL_ADDRESS, $KEY);
48+
echo "✅ Logged in successfully!\n";
3049

31-
$copyleaks = new Copyleaks();
32-
$loginResult = $copyleaks->login(<your email>,<your api key>);
33-
echo json_encode($loginResult);
3450
```
35-
* (Option) To change the Identity server URI (default:"https://id.copyleaks.com"):
36-
```rb
37-
CopyleaksConfig::SET_IDENTITY_SERVER_URI("<your identity server URI>");
51+
For a detailed understanding of the authentication process, refer to the Copyleaks Login Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/account/login).
52+
##
53+
### Submit Text for Plagiarism Scan
54+
This example shows how to prepare and submit raw text content for a plagiarism scan.
55+
56+
```php
57+
<?php
58+
59+
require_once(__DIR__ . '/vendor/autoload.php');
60+
61+
use Copyleaks\Copyleaks;
62+
use Copyleaks\CopyleaksFileSubmissionModel;
63+
use Copyleaks\SubmissionProperties;
64+
use Copyleaks\SubmissionWebhooks;
65+
66+
// --- Your Credentials ---
67+
$EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
68+
$KEY = 'YOUR_API_KEY';
69+
$WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
70+
// --------------------
71+
72+
// Prepare your content for scanning
73+
echo "Submitting text for scanning...\n";
74+
$textToScan = "Hello world, this is a test.";
75+
$base64Content = base64_encode($textToScan);
76+
$scanId = time();
77+
78+
// Configure the scan
79+
$webhooks = new SubmissionWebhooks($WEBHOOK_URL);
80+
$properties = new SubmissionProperties($webhooks);
81+
$properties->setSandbox(true); // Turn on sandbox mode for testing
82+
83+
$submission = new CopyleaksFileSubmissionModel($base64Content, 'test.txt', $properties);
84+
85+
// Submit the scan to Copyleaks
86+
$copyleaks->submitFile($loginToken, $scanId, $submission);
87+
echo "🚀 Scan submitted successfully! Scan ID: " . $scanId . "\n";
88+
echo "You will be notified via your webhook when the scan is complete.\n";
89+
3890
```
39-
* (Option) To change the API server URI (default:"https://api.copyleaks.com"):
40-
```rb
41-
CopyleaksConfig::SET_API_SERVER_URI("<your API server URI>");
91+
For a full guide please refer to our step by step [Guide](https://docs.copyleaks.com/guides/authenticity/detect-plagiarism-text)
92+
93+
For a detailed understanding of the plagiarism detection process, refer to the Copyleaks Submit Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/scans/submit-file)
94+
##
95+
### AI-Generated Text Detection
96+
Use the AI detection client to determine if content was generated by artificial intelligence.
97+
98+
```php
99+
<?php
100+
101+
require_once(__DIR__ . '/vendor/autoload.php');
102+
103+
use Copyleaks\Copyleaks;
104+
use Copyleaks\CopyleaksNaturalLanguageSubmissionModel;
105+
106+
// --- Your Credentials ---
107+
$EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
108+
$KEY = 'YOUR_API_KEY';
109+
$WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
110+
// --------------------
111+
112+
$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.";
113+
114+
$submission = new CopyleaksNaturalLanguageSubmissionModel(
115+
$sampleText,
116+
);
117+
$submission->sandbox = true;
118+
119+
$response = $this->copyleaks->aiDetectionClient->submitNaturalLanguage($authToken, time(), $submission);
120+
$this->logInfo('AI Detection - submitNaturalLanguage', $response);
121+
42122
```
43123

44-
## Demo
45-
See [demo.php](./demo/demo.php) under demo folder for an example.
46-
## Read More
47-
* [API Homepage](https://api.copyleaks.com/)
48-
* [API Documentation](https://api.copyleaks.com/documentation)
49-
* [Plagiarism Report](https://github.com/Copyleaks/plagiarism-report)
124+
### Writing Assistant
125+
Get intelligent suggestions for improving grammar, spelling, style, and overall writing quality.
126+
127+
```php
128+
<?php
129+
130+
require_once(__DIR__ . '/vendor/autoload.php');
131+
132+
use Copyleaks\Copyleaks;
133+
use Copyleaks\CopyleaksWritingAssistantSubmissionModel;
134+
135+
// --- Your Credentials ---
136+
$EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
137+
$KEY = 'YOUR_API_KEY';
138+
$WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
139+
// --------------------
140+
141+
$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.";
142+
143+
$scoreWeights = new ScoreWeights(
144+
0.1, 0.2, 0.3, 0.4
145+
);
146+
147+
$submission = new CopyleaksWritingAssistantSubmissionModel(
148+
$sampleText,
149+
);
150+
151+
$submission->sandbox = true;
152+
$submission->score = $scoreWeights;
153+
154+
$response = $this->copyleaks->writingAssistantClient->submitText($authToken, time(), $submission);
155+
$this->logInfo('Writing Assistant - submitText', $response);
156+
157+
```
158+
For a full guide please refer to our step by step [Guide](https://docs.copyleaks.com/guides/writing/check-grammar/)
159+
160+
For a detailed understanding of the Writing assistant process, refer to the Copyleaks writing feedback Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/writing-assistant/check/)
161+
##
162+
### Text Moderation
163+
Scan and moderate text content for unsafe, inappropriate, or policy-violating material across various categories.
164+
165+
```php
166+
<?php
167+
168+
require_once(__DIR__ . '/vendor/autoload.php');
169+
170+
use Copyleaks\Copyleaks;
171+
use Copyleaks\CopyleaksTextModerationRequestModel;
172+
173+
// --- Your Credentials ---
174+
$EMAIL_ADDRESS = 'YOUR_EMAIL_ADDRESS';
175+
$KEY = 'YOUR_API_KEY';
176+
$WEBHOOK_URL = 'https://your-server.com/webhook/{STATUS}';
177+
// --------------------
178+
179+
$textModerationRequest = new CopyleaksTextModerationRequestModel(
180+
"This is some text to scan.", // text
181+
true, // sandbox mode
182+
"en", // language
183+
[
184+
["id" => "adult-v1"],
185+
["id" => "toxic-v1"],
186+
["id" => "violent-v1"],
187+
["id" => "profanity-v1"],
188+
["id" => "self-harm-v1"],
189+
["id" => "harassment-v1"],
190+
["id" => "hate-speech-v1"],
191+
["id" => "drugs-v1"],
192+
["id" => "firearms-v1"],
193+
["id" => "cybersecurity-v1"]
194+
] // labels
195+
);
196+
197+
$response = $this->copyleaks->textModerationClient->submitText($authToken, time(), $textModerationRequest);
198+
$textModerationResponse= CopyleaksTextModerationResponseModel::fromArray(json_decode(json_encode($response), true));
199+
200+
$this->logInfo('Text Moderation - submitText', $textModerationResponse);
201+
202+
```
203+
For a full guide please refer to our step by step [Guide](https://docs.copyleaks.com/guides/moderation/moderate-text/)
204+
205+
For a detailed understanding of the Text moderation process, refer to the Copyleaks text moderation Endpoint [Documentation](https://docs.copyleaks.com/reference/actions/text-moderation/check/)
206+
##
207+
## Further Resources
208+
209+
* **Copyleaks API Dashboard:** Manage your API keys, monitor usage, and view analytics from your personalized dashboard. [Access Dashboard](https://api.copyleaks.com/dashboard)
210+
* **Copyleaks SDK Documentation:** Explore comprehensive guides, API references, and code examples for seamless integration. [Read Documentation](https://docs.copyleaks.com/resources/sdks/overview/)
211+
212+
213+
## Support
214+
* If you need assistance, please contact Copyleaks Support via our support portal: Contact Copyleaks [Support](https://help.copyleaks.com/s/contactsupport).
215+
* To arrange a product demonstration, book a demo here: [Booking Link](https://copyleaks.com/book-a-demo).

0 commit comments

Comments
 (0)