Skip to content

Conversation

@Hugo-Prossaird
Copy link

@Hugo-Prossaird Hugo-Prossaird commented Dec 8, 2025

Summary

Sync with Mautic 5 upstream and add Webmecanik-specific features for version 4.0.0.

Changes

  • PSR-18 HTTP Client: Now uses PSR-18 compatible HTTP client instead of cURL
  • PHP 8.0+ Required: Minimum PHP version is now 8.0
  • TwoLeggedOAuth2: Added client credentials OAuth2 authentication (PSR-18 compatible)
  • sendCustomToContact: Send custom emails to contacts without pre-defined templates
  • Contacts API: Added optional query arguments for Custom Objects support
  • Point Groups API: New API context for Mautic 5.x point groups

PHP Examples

TwoLeggedOAuth2 (Client Credentials)

use Mautic\Auth\ApiAuth;
use Mautic\MauticApi;

$settings = [
    'baseUrl'      => 'https://mautic.example.com',
    'clientKey'    => 'your_client_id',
    'clientSecret' => 'your_client_secret',
];

$auth = (new ApiAuth())->newAuth($settings, 'TwoLeggedOAuth2');
$api = (new MauticApi())->newApi('contacts', $auth, $settings['baseUrl'] . '/api/');

// Token management
if (!$auth->isAuthorized()) {
    $auth->requestAccessToken();
}
$tokenData = $auth->getAccessTokenData(); // For caching

sendCustomToContact

$emailApi = (new MauticApi())->newApi('emails', $auth, $apiUrl);

$response = $emailApi->sendCustomToContact($contactId, [
    'fromEmail' => 'noreply@example.com',
    'fromName'  => 'My App',
    'subject'   => 'Hello {{contactfield=firstname}}!',
    'content'   => '<p>Custom HTML content with tokens</p>',
]);

if ($response['success']) {
    echo "Email sent! Tracking hash: " . $response['trackingHash'];
}

Note: This feature requires Mautic with PR #12854 merged.
It is not available in standard Mautic 5.x releases.

Contacts with Custom Objects query args

$contactApi = (new MauticApi())->newApi('contacts', $auth, $apiUrl);

// Create with query arguments for Custom Objects
$response = $contactApi->create(
    ['email' => 'test@example.com', 'firstname' => 'John'],
    ['includeCustomObjects' => true]
);

Point Groups API (Mautic 5.x)

$contactApi = (new MauticApi())->newApi('contacts', $auth, $apiUrl);

// Get point group scores
$scores = $contactApi->getPointGroupScores($contactId);

// Add/subtract points
$contactApi->addPointGroupScore($contactId, $groupId, 10);
$contactApi->subtractPointGroupScore($contactId, $groupId, 5);

Test plan

  • All PHPUnit tests pass
  • PHPStan static analysis passes
  • PHP-CS-Fixer code style passes
  • TwoLeggedOAuth2 authentication works
  • sendCustomToContact tested with kuzmany/mautic fork (PR #12854)
  • Contacts create/createBatch with query args works
  • Backward compatibility with existing code

🤖 Generated with Claude Code

Rocksheep and others added 30 commits October 14, 2022 14:41
Co-authored-by: John Linhart <jan@linhart.email>
Fix for 
Deprecated
: strlen(): Passing null to parameter #1 ($string) of type string is deprecated in api-library/lib/Auth/OAuth.php on 
- line 388
- line 395
- line 637
deleted strlen() completely from lines
…lveig

docs: add LadySolveig as a contributor for code
docs: add escopecz as a contributor for review
…deprecated-strlen-OAuth-php8.1

Fix - Deprecated PHP 8.1
Co-authored-by: John Linhart <jan@linhart.email>
# Conflicts:
#	composer.lock
escopecz and others added 24 commits September 18, 2024 15:23
…cause it uses a deprecated version of `actions/upload-artifact: v2`
If authentications fails - mark it as such.
Authentication requires stronger password.
Fix conflicting GPG key and PPA installation errors in the Install Apache step in CI
Install Apache without PPA on ubuntu-24.04
Features added:
- TwoLeggedOAuth2: Client credentials OAuth2 authentication (PSR-18 compatible)
- sendCustomToContact: Send custom emails to contacts (from PR mautic#241)
- Contacts::create/createBatch: Optional query arguments for Custom Objects support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Installation changes (PSR-18 HTTP client)
- TwoLeggedOAuth2 method changes
- New features documentation
- Version compatibility table

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Hugo-Prossaird and others added 2 commits December 9, 2025 08:56
Conflicts resolved:
- .php-cs-fixer.php: kept aligned spacing style
- lib/Auth/AbstractAuth.php: kept GET-only URL param separation fix with modern syntax
- lib/Auth/TwoLeggedOAuth2.php: kept PSR-18 compatible implementation with token management

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The merge caused duplicate method definitions. Removed the first
set and kept the well-documented versions with Custom Objects support.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Hugo-Prossaird Hugo-Prossaird marked this pull request as ready for review December 9, 2025 08:05
Hugo-Prossaird and others added 2 commits December 9, 2025 09:07
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Document correct Mautic API parameters: fromEmail, subject, content
- Add note about Mautic PR #12854 requirement
- Update UPGRADE-4.0.md with complete example

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.