PHP code example of tigusigalpa / manus-ai-php

1. Go to this page and download the library: Download tigusigalpa/manus-ai-php 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/ */

    

tigusigalpa / manus-ai-php example snippets


use Tigusigalpa\ManusAI\ManusAIClient;

$client = new ManusAIClient($_ENV['MANUS_AI_API_KEY']);

$task = $client->createTask('Write a concise release note for this PHP package.', [
    'agent_profile' => 'standard',
    'title' => 'Release note',
]);

printf("Created %s: %s\n", $task['task_id'], $task['task_url']);

$client = new ManusAIClient('your-api-key');

$client = new ManusAIClient('', bearerToken: 'oauth-access-token');

$client = new ManusAIClient(
    apiKey: $_ENV['MANUS_AI_API_KEY'],
    timeout: 45,
    defaultTaskOptions: ['locale' => 'en-US', 'share_visibility' => 'private'],
);

use Tigusigalpa\ManusAI\Helpers\AgentProfile;
use Tigusigalpa\ManusAI\Helpers\TaskAttachment;

$task = $client->createTask('Summarize the attached report.', [
    'agent_profile' => AgentProfile::STANDARD, // standard, lite, or max
    'locale' => 'en-US',
    'title' => 'Report summary',
    'project_id' => 'project_123',
    'hide_in_task_list' => false,
    'share_visibility' => 'private', // private, team, or public
    'interactive_mode' => true,
    'structured_output_schema' => [
        'type' => 'object',
        'properties' => ['summary' => ['type' => 'string']],
        '

$detail = $client->getTask($task['task_id']);
echo $detail['status'];

$tasks = $client->getTasks([
    'limit' => 20,
    'order' => 'desc',
    'scope' => 'all',
    'project_id' => 'project_123',
]);

$client->updateTask($task['task_id'], [
    'title' => 'Revised title',
    'enable_visible_in_task_list' => true,
    'share_visibility' => 'team',
]);

$client->deleteTask($task['task_id']);

$messages = $client->listMessages($task['task_id'], limit: 50, order: 'desc', verbose: true);

$client->sendMessage(
    $task['task_id'],
    'Please make the summary more concise.',
    options: ['agent_profile' => 'lite'],
);

$client->stopTask($task['task_id']);

$client->confirmAction($task['task_id'], 'event_123', ['confirmed' => true]);

use Tigusigalpa\ManusAI\Helpers\TaskAttachment;

$file = $client->createFile('report.pdf');
$client->uploadFileContent(
    $file['upload_url'],
    file_get_contents('/path/to/report.pdf'),
    'application/pdf',
);

$attachment = TaskAttachment::fromFileId($file['file_id']);
$client->createTask('Review the attached report.', ['attachments' => [$attachment]]);

$webhook = $client->createWebhook([
    'url' => 'https://example.com/webhooks/manus',
]);

echo $webhook['webhook_id'];

use Tigusigalpa\ManusAI\Helpers\WebhookHandler;

$payload = WebhookHandler::parsePayload($request->getContent());

if (WebhookHandler::isTaskCompleted($payload)) {
    $attachments = WebhookHandler::getAttachments($payload);
}
if (WebhookHandler::isTaskAskingForInput($payload)) {
    // Obtain the event ID from task.listMessages and call confirmAction().
}

use Tigusigalpa\ManusAI\Contracts\ManusAIClientInterface;
use Tigusigalpa\ManusAI\Laravel\ManusAI;

// Dependency injection
function createReleaseNote(ManusAIClientInterface $manus): array
{
    return $manus->createTask('Write a release note.');
}

// Or the facade
$task = ManusAI::createTask('Write a release note.');
bash
composer 
bash
php artisan vendor:publish --tag=manus-ai-config
bash
php artisan manus-ai:test
php artisan manus-ai:task create --prompt="Write a release note" --profile=standard
php artisan manus-ai:task list --limit=10
php artisan manus-ai:task get --id=task_123
php artisan manus-ai:task update --id=task_123 --title="Revised title"
php artisan manus-ai:task delete --id=task_123