Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,43 @@

All notable changes to `fopost/sdk` are documented here.

## 0.4.0 - 2026-10-18

### Added

- `$client->queue()` wraps the posting queue: `listSlots`, `createSlot`, `updateSlot`,
`deleteSlot`, `next` and `preview`, with `QueueSlot`, `QueueMove`, `QueueSlotUpdate` and
`QueueSlotDeletion`. `posts()->create()` and `update()` take `schedule: 'queue'`.
- `$client->posts()->unpublish()` takes a published post down everywhere and answers an
`UnpublishResult` with one `PlatformRemoval` per network. `validateBulkImport()`,
`commitBulkImport()` and `rollbackBulkImport()` wrap the CSV import.
- `$client->connectSessions()` creates and reads hosted connect links (`ConnectSession`).
- `$client->webhooks()` manages endpoints (`list`, `create`, `update`, `delete`, `test`) and
their delivery log (`listDeliveries`, `getDelivery`, `redeliver`), with `Webhook` and
`WebhookDelivery`.
- `$client->automations()` wraps `/automations`: `list`, `stats`, `get`, `create`, `update`,
`delete`, `toggle`, versions (`listVersions`, `getVersion`, `restoreVersion`) and runs
(`listRuns`, `getRun`), with `Automation`, `AutomationStep`, `AutomationStats`,
`AutomationVersion`, `AutomationNodeRef`, `AutomationRestore`, `AutomationRun`,
`AutomationRunLog` and `AutomationToggle`.
- `$client->workspaces()->create()`, `update()`, `delete()` and `analytics()` (`WorkspaceAnalytics`,
`WorkspaceAccountStats`). `Workspace` carries
`connectRedirectDomains` and `updatedAt`.
- `$client->accounts()->validate()` (`AccountValidation`), `refreshToken()`, `togglePrimary()`
(`AccountPrimary`) and `analyticsHistory()` (`AccountAnalyticsHistory`, `AccountSnapshot`).
- `$client->accounts()` X communities: `listCommunities`, `syncCommunities`,
`searchCommunities`, `addCommunity` and `removeCommunity` (`XCommunity`, `XCommunityMatch`).
- `$client->logs()->list()` reads the request log into `RequestLogPage` (`RequestLog`,
`RequestLogBucket`).
- `$client->analytics()` dashboard calls: `overview`, `timeSeries`, `topPosts`, `labels`,
`postsTable`, `postingStreak`, `demographics` and `inbox`, with `AnalyticsOverview`,
`AnalyticsAccountTotal`, `AnalyticsTimeSeries`, `AnalyticsSeriesPoint`, `TopPost`,
`LabelAnalytics`, `PostsTablePage`, `PostsTableRow`, `PostingStreakDay`,
`AudienceDemographics`, `DemographicsBucket` and `InboxAnalytics`.
- `$client->media()->upload()` sends files through the API in one multipart request;
`list()` pages through the library and `delete()` removes a file. `MediaAsset` carries every
library field (`mimeType`, `tags`, `brandRole`, `hasPersonConsent`, `share`, ...).

## 0.3.0 - 2026-10-18

### Removed
Expand Down
18 changes: 10 additions & 8 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exception per error status. PSR-4 autoload root `Fopost\Sdk\` → `src/`.

- **PHP >= 8.1.** Extensions `ext-curl` and `ext-json` are the only runtime requirements —
there are no Composer runtime dependencies, and none may be added.
- Version `0.3.0`, declared in `Fopost\Sdk\Client::VERSION`. `composer.json` carries no
- Version `0.4.0`, declared in `Fopost\Sdk\Client::VERSION`. `composer.json` carries no
`version` key (Packagist reads the git tag).

## Downstream Packages
Expand Down Expand Up @@ -54,9 +54,10 @@ src/
Response.php status + lowercased headers + raw body, pre-decode
Resource/
Resource.php base: unwrap/compact/asArray/iso helpers
PostsResource.php AccountsResource.php AccountGroupsResource.php WorkspacesResource.php
LabelsResource.php AiResource.php InboxResource.php AdsResource.php MediaResource.php
ValidateResource.php
PostsResource.php QueueResource.php AccountsResource.php ConnectSessionsResource.php
AccountGroupsResource.php WorkspacesResource.php LabelsResource.php AiResource.php
AutomationsResource.php InboxResource.php AdsResource.php MediaResource.php
ValidateResource.php WebhooksResource.php AnalyticsResource.php LogsResource.php ...
Model/
Model.php base: reads both wire casings, keeps the untouched payload on ->raw
Page.php PageMeta.php Post.php SocialAccount.php Workspace.php Label.php ...
Expand Down Expand Up @@ -90,10 +91,11 @@ throws through `ErrorFactory` or returns the decoded body → the resource calls
- `PostsResource::iterate()` / `iteratePages()` are generators that page through the list
endpoint; `Page` is `IteratorAggregate + Countable + ArrayAccess` and read-only.

**Resources wired today:** `posts`, `accounts`, `accountGroups`, `workspaces`, `labels`, `ai`,
`inbox`, `contacts`, `broadcasts`, `sequences`, `ads`, `media`, `validate`. There is no `communities`, `webhooks`, `analytics`, or
`automations` resource here — reach those through the escape hatch `Client::request()` until one
is added.
**Resources wired today:** `posts`, `queue`, `accounts`, `connectSessions`, `accountGroups`,
`workspaces`, `labels`, `ai`, `automations`, `inbox`, `contacts`, `broadcasts`, `sequences`, `blog`,
`knowledge`, `ads`, `blogs`, `media`, `validate`, `webhooks`, `whatsapp`, `analytics`, `googleBusiness`,
`activity`, `logs`. Anything else goes through the escape hatch `Client::request()` until a
resource is added. `scripts/sdk-gaps.mjs` in `fopost-api-collections` lists what is still unwrapped.

- `inbox` (scope `inbox`) covers `/inbox`, `/inbox/posts`, `/inbox/conversations`, `unread-count`,
`accounts`, `platforms`, `read`, `refresh`, `approvals` (+ `approve`/`reject`, integer ids), and
Expand Down
142 changes: 142 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,36 @@ foreach ($client->posts()->deliveries($draft->id) as $delivery) {
}
```

Drop a post into the next free posting slot instead of picking a time, take a
published post down everywhere, or create many posts from a CSV:

```php
$client->posts()->create($workspaceId, 'Queued', accounts: [$accountId], schedule: 'queue');
$client->posts()->update($post->id, schedule: 'queue');

$result = $client->posts()->unpublish($post->id);
echo $result->postStatus; // "unpublished"; $result->deliveries[0]->removed per network

$check = $client->posts()->validateBulkImport($workspaceId, 'posts.csv');
if ($check->invalidRows === 0) {
$batch = $client->posts()->commitBulkImport($workspaceId, 'posts.csv');
$client->posts()->rollbackBulkImport($batch->batchId); // deletes everything it created
}
```

## Queue

The weekly slots a post created with `schedule: 'queue'` lands in. Needs the `posts` scope.

```php
$slot = $client->queue()->createSlot($workspaceId, weekday: 1, time: '09:00', timezone: 'Europe/Zagreb');
$client->queue()->updateSlot($slot->id, time: '10:00'); // ->moved lists the posts that shifted
$client->queue()->listSlots($workspaceId);
$client->queue()->next($workspaceId); // DateTimeImmutable or null
$client->queue()->preview($workspaceId, count: 5); // the next five times
$client->queue()->deleteSlot($slot->id);
```

## Accounts

```php
Expand Down Expand Up @@ -196,6 +226,33 @@ $flairs = $client->accounts()->listRedditFlairs('acc_1', 'webdev');
$client->accounts()->setRedditDefaultSubreddit('acc_1', 'webdev');
```

X communities linked to an account:

```php
$client->accounts()->syncCommunities($accountId);
$matches = $client->accounts()->searchCommunities($accountId, 'PHP');
$community = $client->accounts()->addCommunity($accountId, $matches[0]->id);
$client->accounts()->removeCommunity($accountId, $community->id);
```

## Connect sessions

Hosted connect links for your own users. Send the user to `url`, then poll until the
session is `used`. Needs the `accounts` scope.

```php
$session = $client->connectSessions()->create(
externalUserId: 'user-42',
platforms: ['linkedin', 'threads'],
workspaceId: $workspaceId,
redirectUrl: 'https://yourbrand.com/connected',
);
echo $session->url;

$session = $client->connectSessions()->get($session->id);
echo $session->status, ' ', $session->accountId;
```

## Google Business Profile

Manage a connected Business Profile location: the profile, attributes, food menus, services, photos, action links, verification and performance.
Expand Down Expand Up @@ -238,6 +295,12 @@ $workspace = $client->workspaces()->get($workspaceId);
echo $workspace->name, ' ', $workspace->timezone, PHP_EOL;
```

```php
$workspace = $client->workspaces()->create('Client', type: 'CLIENT', timezone: 'Europe/Zagreb');
$client->workspaces()->update($workspace->id, requireApproval: true, connectRedirectDomains: ['yourbrand.com']);
$client->workspaces()->delete($workspace->id); // 409 while accounts are still connected
```

## Labels

```php
Expand Down Expand Up @@ -737,6 +800,15 @@ $upload = $client->media()->presign($workspaceId, 'clip.mp4', 'video/mp4', files
$asset = $client->media()->complete($upload->uploadId);
```

Or send the bytes through the API in one multipart request:

```php
$assets = $client->media()->upload(['logo.png', 'clip.mp4'], $workspaceId);

$page = $client->media()->list($workspaceId, type: 'image', brandRole: 'logo');
$client->media()->delete($page->items[0]->id);
```

A file over the limit is a `413` with `error: file_too_large`; it arrives as an `ApiException` whose
`getBody()['max_file_bytes']` says what would have fit, and `getBody()['upgrade_url']` where to raise it.

Expand Down Expand Up @@ -827,6 +899,21 @@ hand on the network works the same way:

```php
$client->analytics()->timeline('https://x.com/acme/status/1');
The numbers the dashboard shows:

```php
$overview = $client->analytics()->overview(days: 30, workspaceId: $workspaceId);
echo $overview->totalFollowers, ' ', $overview->engagementRate, PHP_EOL;

$series = $client->analytics()->timeSeries(from: '2026-03-01', to: '2026-03-31');
$top = $client->analytics()->topPosts(limit: 10, sort: 'engagements');
$labels = $client->analytics()->labels(days: 90);
$table = $client->analytics()->postsTable(page: 1, perPage: 20);
$streak = $client->analytics()->postingStreak($workspaceId);
$audience = $client->analytics()->demographics('followers', accountId: $accountId);
$inbox = $client->analytics()->inbox(days: 30, tz: 'Europe/Zagreb');
```

## Activity

What happened in a workspace, newest first. Needs the `analytics` scope.
Expand All @@ -846,6 +933,61 @@ signed-in devices. Those rows are append-only and never expire.
$audit = $client->activity()->list('w_1', 'security');
```

## Logs

The API requests made with your keys, newest first, with error counts per bucket. Needs the
`workspaces` scope.

```php
$page = $client->logs()->list($workspaceId, days: 7, status: 'error');
$page->logs[0]->route; // "/v1/posts/{id}"
$page->logs[0]->statusCode; // 422
$page->nextCursor; // pass back as $before for the next page
```

## Webhooks

The endpoints FoPost sends events to, and their delivery log. Verify what arrives with
`Fopost\Sdk\Webhooks::verify()`. Needs the `webhooks` scope.

```php
$hook = $client->webhooks()->create($workspaceId, 'https://yourbrand.com/hooks', ['post.published']);
echo $hook->secret; // returned once

$client->webhooks()->update($hook->id, events: ['post.published', 'post.failed'], active: true);
$client->webhooks()->test($hook->id);

foreach ($client->webhooks()->listDeliveries($hook->id, status: 'failed') as $delivery) {
$client->webhooks()->redeliver($hook->id, $delivery->id);
}
$delivery = $client->webhooks()->getDelivery($hook->id, $deliveryId); // ->payload as sent
$client->webhooks()->delete($hook->id);
```

## Automations

Triggers and the step chains they run. Needs the `automations` scope.

```php
$automation = $client->automations()->create(
$workspaceId,
'Cross-post',
'content_created',
['accountIds' => [$accountId]],
steps: [['actionType' => 'publish', 'actionConfig' => ['accountIds' => [$otherAccountId]]]],
);
$client->automations()->update($automation->id, active: false);
$client->automations()->toggle($automation->id);
$client->automations()->stats();

$versions = $client->automations()->listVersions($automation->id);
$client->automations()->restoreVersion($automation->id, $versions->items[1]->version);

$runs = $client->automations()->listRuns($automation->id);
$run = $client->automations()->getRun($automation->id, $runs->items[0]->id); // ->logs per step
$client->automations()->delete($automation->id);
```

## Blogs, articles and products

Content a connected site already owns: the articles on a WordPress site or a
Expand Down
Loading
Loading