plainrouter/sdk to call the Plainrouter Conversion API from PHP. Published version 0.4.1 targets signed API contract 0.5.0; it provides event and operations groups. Its generated sandbox methods target retired endpoints and must not be used for connection checks. The generated client does not call Meta’s Graph API directly.
Requirements and installation
You need PHP 8.2 or newer with cURL, JSON and mbstring, plus Composer. For production, store a workspace Server secret in your server’s secret manager, connect the intended Meta dataset, and record the actual advertising consent. Install the released package:What changes when upgrading?
Version0.4.1 adds curated agentContext and fileImports handling, corrects the Launcher import route, and decodes asynchronous documented errors through their generated models while retaining status and raw body. Inventory 404 can contain ApiRouteNotFound or an account error; inspect the branch instead of assuming a message-only response.
The 0.4.x series exposes more operation groups through the curated client, including actionReads, actionRules, adTests, cookieDeclarations, creatives and inventory. adTests and legacy import methods can remain in the package although the service routes are retired. Use an appropriately scoped Workspace key for supported Actions operations; the Server secret in the conversion example does not grant Actions access.
Use named arguments when calling generated methods whose pagination or content-type parameters changed. For example, launchPlansIndex(1, 50) can now mean page 50 rather than a page size of 50; use launchPlansIndex(workspace: 1, per_page: 50). Replace the removed Plainrouter\OpenAPI\Model\DeploymentPlan with DeploymentPlanRead.
The curated client defaults to JSON responses and rejects redirects with Plainrouter\OpenAPI\ApiException, retaining status and response headers. Follow returned cursors for incomplete collections. Review the published release notes and shared upgrade checks.
What happened to sandbox methods?
The unauthenticated sandbox is retired. A generated sandbox method can remain in the installed package, but calling it returns HTTP410 with sandbox_retired. Configure your Server secret for supported Signals operations below. Migration guidance.
Configure production access
https://plainrouter.com/api/v1. Keep the secret out of source control, browser code and logs. A successful empty list is valid; it does not prove browser installation or Meta delivery. verifySignalIngestion() is a separate identity-free diagnostic write and does not replace a browser arrival.
Send a Meta conversion
Choose your backend as the purchase owner and confirm payment before sending. Persist the event body first. This example assumes$order and $consent come from your own recorded order and consent data; it can create a real conversion.
consent.captured_at locally when visitor identity is present; this does not obtain consent or replace server validation.
New ingestion returns HTTP 202; an identical event-ID retry can return 200 with duplicate: true. Reuse the persisted body after an uncertain timeout, checking that advertising use remains permitted. A duplicate does not update the original event or replay a failed delivery.
Inspect the event’s deliveries separately. accepted confirms destination acceptance; queued or retrying work remains pending. Acceptance does not prove attribution or better ad performance. See delivery statuses.
Troubleshooting
API failures use
Plainrouter\OpenAPI\ApiException; inspect the HTTP code without logging its credential-bearing request or customer payload. Generated models and lower-level APIs live under Plainrouter\OpenAPI.
Continue with Conversion API handling and deduplication.