1. Go to this page and download the library: Download markupai/php-sdk 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/ */
markupai / php-sdk example snippets
use MarkupAI\MarkupAiClient;
use MarkupAI\Laravel\Facades\MarkupAi;
// Constructor injection
public function __construct(MarkupAiClient $client)
{
$this->client = $client;
}
// Facade usage
$styleGuides = MarkupAi::styleGuides()->list();
arkupAI\MarkupAiClient;
// Initialize the client
$client = new MarkupAiClient('your-api-token');
// List all style guides
$styleGuides = $client->styleGuides()->list();
// Create a style check with file upload
$styleCheck = $client->styleChecks()->createWithFile([
'dialect' => 'american_english',
'style_guide' => 'your-style-guide-id'
], '/path/to/your/document.txt');
// Get style suggestions with file upload
$suggestions = $client->styleSuggestions()->createWithFile([
'dialect' => 'american_english',
'style_guide' => 'your-style-guide-id',
'tone' => 'professional'
], '/path/to/your/document.txt');
// Generate a style rewrite with file upload
$rewrite = $client->styleRewrites()->createWithFile([
'dialect' => 'american_english',
'style_guide' => 'your-style-guide-id',
'tone' => 'professional'
], '/path/to/your/document.txt');
// List all style guides
$styleGuides = $client->styleGuides()->list();
// Create a new style guide
$styleGuide = $client->styleGuides()->create([
'name' => 'My Style Guide',
'description' => 'A custom style guide'
]);
// Get a specific style guide
$styleGuide = $client->styleGuides()->get('style-guide-id');
// Update a style guide
$styleGuide = $client->styleGuides()->update('style-guide-id', [
'name' => 'Updated Style Guide'
]);
// Delete a style guide
$client->styleGuides()->delete('style-guide-id');
// Create a style check with file upload (ateWithFile([
'dialect' => 'american_english',
'style_guide' => 'your-style-guide-id'
], '/path/to/document.txt');
// Get style check results
$styleCheck = $client->styleChecks()->get('style-check-id');
// Check if completed
if ($styleCheck->isCompleted()) {
$results = $styleCheck->getResults();
// Access issues and scores
$issues = $results['original']['issues'] ?? [];
$qualityScore = $results['original']['scores']['quality']['score'] ?? null;
}
// Create a style rewrite with file upload
$rewrite = $client->styleRewrites()->createWithFile([
'dialect' => 'american_english',
'style_guide' => 'your-style-guide-id',
'tone' => 'professional'
], '/path/to/document.txt');
// Get rewritten content
$rewrite = $client->styleRewrites()->get('rewrite-id');
if ($rewrite->isCompleted()) {
$rewrittenContent = $rewrite->getRewrittenContent();
}
use GuzzleHttp\Client as GuzzleClient;
use Nyholm\Psr7\Factory\Psr17Factory;
$httpClient = new GuzzleClient();
$factory = new Psr17Factory();
$client = new MarkupAiClient(
token: 'your-api-token',
httpClient: $httpClient,
requestFactory: $factory,
streamFactory: $factory
);
$client = new MarkupAiClient(
token: 'your-api-token',
baseUrl: 'https://custom-api.markup.ai/v1'
);