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
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ All notable changes to `fopost/sdk` are documented here.
`BlogWebsiteTest`, `BlogKeyword`, `BlogArticle`, `BlogArticleFull`, `BlogArticleImage` and
`BlogArticleWebhookPayload` models, and `WebhookEvent::article()`. The API no longer serves
them; articles are ordinary posts. `$client->blogs()` is unchanged.
- **Breaking:** the ads campaign tree and network objects: `accountTree()`, `createCampaign()`,
`campaign()`, `updateCampaign()`, `deleteCampaign()`, `duplicateCampaign()`, `createAdSet()`,
`adSet()`, `updateAdSet()`, `deleteAdSet()`, `duplicateAdSet()`, `createNetworkAd()`,
`networkAd()`, `updateNetworkAd()`, `deleteNetworkAd()` and `duplicateNetworkAd()`, with the
`AdAccountTree`, `AdCampaign`, `AdSet` and `NetworkAd` models. The API no longer serves them.
`bulkSetStatus()` and the `$client->ads()` methods on `/ads` and `/ads/{id}` are unchanged.
- **Breaking:** creatives (`creatives()`, `createCreative()`, `creative()`, `deleteCreative()` and
`AdCreative`), product catalogs (`catalogs()`, `createCatalog()`, `getCatalog()`,
`updateCatalog()`, `deleteCatalog()`, `catalogProducts()`, `writeCatalogProducts()`,
`productFeeds()`, `createProductFeed()`, `deleteProductFeed()`, `feedUploads()`,
`startFeedUpload()`, `productSets()`, `createProductSet()`, `updateProductSet()`,
`deleteProductSet()` and their models) and the Ad Library (`library()`, `AdLibraryPage`,
`AdLibraryEntry`). The API no longer serves them.
- **Breaking:** the Google keyword, search term, negative keyword list, asset, asset group,
recommendation and optimization score methods on `$client->ads()->google()`, with their
`Google*` models. Bid strategies, the ad schedule, Local Services leads, conversions and
`query()` are unchanged.

## 0.4.0 - 2026-10-18

Expand Down
24 changes: 12 additions & 12 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ src/
Ad.php AdInsights.php ExternalAd.php AdConnection.php AdSource.php BoostablePost.php
Audience.php AudiencesResult.php CreatedAudience.php TargetingOption.php
LeadForm.php LeadFormSource.php Lead.php LeadsPage.php LeadFormDetail.php FeedLead.php LeadsFeedPage.php LeadPage.php
AdAccountTree.php AdCampaign.php AdSet.php NetworkAd.php AdCreative.php BulkAdStatusResult.php
BulkAdStatusResult.php
AdInsightsReport.php InsightsMetrics.php InsightsRow.php ReachEstimate.php
AdPixel.php AdPixelDetail.php AdPixelStats.php AdPixelEventCount.php EventMatchQuality.php EventMatchKey.php
ConversionUploadResult.php ConversionBatch.php ConversionBatchEvent.php CustomConversion.php CustomConversionRule.php
Expand Down Expand Up @@ -120,17 +120,17 @@ resource is added. `scripts/sdk-gaps.mjs` in `fopost-api-collections` lists what
own `PageMeta`. A recipient's `skipReason` is the messaging window's record: `window_closed`
means the network's 24-hour window had shut and nothing was attempted, so a sent count lower
than the audience is correct rather than a failure.
- `ads` (scope `ads`) covers the full `/ads` family: ads, external ads, boostable posts,
connections (+ Meta authorize), sources, boost, create, refresh, status, delete, audiences,
targeting search, lead forms and leads, plus the campaign tree (campaigns, ad sets, network ads,
duplicate, bulk status), creatives, audience detail and users, reach, insights, and the stored leads
feed with Page subscriptions, plus pixels (`pixels`, `createPixel`, `pixel`, `updatePixel`, `sharePixel`,
`pixelStats`, `eventMatchQuality`), the Conversions API (`uploadConversions`, `sendConversions` with a required
`Idempotency-Key`, `listConversionEvents`) and custom conversions. `sendConversionEvents()` is the older
LinkedIn conversion-rule send, hence the different name. `boost()`, `create()`, `setStatus()`, `delete()`, `bulkSetStatus()` and
every campaign, ad set and network ad write also need the `publish` scope, and anything created
starts paused unless `paused` is `false`. Campaign-tree objects take Meta ids plus `connection_id`
and are read live. An empty update or duplicate body goes out as `{}` because the API rejects none. Request
- `ads` (scope `ads`) covers the `/ads` family: ads, external ads, boostable posts,
connections (+ Meta authorize), sources, boost, create, refresh, status, delete, bulk status by
network id, audiences, targeting search, lead forms and leads, audience detail and users, reach,
insights, and the stored leads feed with Page subscriptions, plus pixels (`pixels`, `createPixel`,
`pixel`, `updatePixel`, `sharePixel`, `pixelStats`, `eventMatchQuality`), the Conversions API
(`uploadConversions`, `sendConversions` with a required `Idempotency-Key`, `listConversionEvents`)
and custom conversions. `ads()->google()` covers bid strategies, the ad schedule, Local Services
leads, conversions and GAQL. `sendConversionEvents()` is the older LinkedIn conversion-rule send,
hence the different name. `boost()`, `create()`, `setStatus()`, `delete()` and `bulkSetStatus()`
also need the `publish` scope, and anything created starts paused unless `paused` is `false`.
An empty update body goes out as `{}` because the API rejects none. Request
bodies are camelCase; query params stay snake_case. `Resource::page()` is the shared
`{data, meta}` → `Page` helper.
- `media` (scope `posts`) is direct upload only: `limits()` → `UploadLimits`, `presign()` →
Expand Down
87 changes: 16 additions & 71 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -600,50 +600,18 @@ $leads = $client->ads()->leads($formId, $connectionId, '555');
$more = $client->ads()->leads($formId, $connectionId, '555', after: $leads->nextCursor);
```

### Campaigns, ad sets and ads
### Bulk status

These are addressed by Meta's own ids plus the `connectionId`, and read live, never stored. Creating, updating, deleting or duplicating any of them, and `bulkSetStatus()`, also need `publish`. New objects start paused unless `paused: false` is passed.
Pause or resume up to 50 campaigns, ad sets or ads at once by the network's own ids. Needs `publish` as well as `ads`.

```php
$tree = $client->ads()->accountTree('act_123', $connectionId); // campaigns → adSets → ads

$campaign = $client->ads()->createCampaign($workspaceId, $connectionId, 'act_123', 'Launch', 'traffic');
$adSet = $client->ads()->createAdSet(
workspaceId: $workspaceId,
connectionId: $connectionId,
campaignId: $campaign->id,
pageId: '555',
name: 'US adults',
goal: 'traffic',
budget: ['minor' => 2500, 'type' => 'daily'],
targeting: ['countries' => ['US'], 'ageMin' => 18, 'ageMax' => 65, 'gender' => 'all'],
);
$creative = $client->ads()->createCreative(
workspaceId: $workspaceId,
connectionId: $connectionId,
adAccountId: 'act_123',
pageId: '555',
name: 'Hero',
format: 'image',
text: 'Meet the new plan',
destinationUrl: 'https://yourbrand.com/plans',
urlTags: 'utm_source=meta&utm_medium=paid',
mediaUrl: $asset->url,
);
$ad = $client->ads()->createNetworkAd($workspaceId, $connectionId, $adSet->id, $creative->id, 'Hero ad');

$client->ads()->updateAdSet($adSet->id, $workspaceId, $connectionId, budgetMinor: 5000);
$copyId = $client->ads()->duplicateCampaign($campaign->id, $workspaceId, $connectionId);
$client->ads()->bulkSetStatus($workspaceId, $connectionId, 'active', [
['id' => $campaign->id, 'level' => 'campaign'],
['id' => $ad->id, 'level' => 'ad'],
['id' => $campaignId, 'level' => 'campaign'],
['id' => $adId, 'level' => 'ad'],
]);
$client->ads()->deleteCampaign($copyId, $workspaceId, $connectionId);
// also: campaign(), adSet(), networkAd(), updateCampaign(), updateNetworkAd(), deleteAdSet(),
// deleteNetworkAd(), duplicateAdSet(), duplicateNetworkAd(), creatives(), creative(), deleteCreative()
```

### Forecasts, conversions and the ad library
### Forecasts and conversions

Available wherever the network's `capabilities` say so — `providers()` reports them.

Expand All @@ -659,8 +627,6 @@ $client->ads()->attachConversionRule($ruleId, $workspaceId, $connectionId, $adSe
$client->ads()->conversionMetrics($ruleId, $workspaceId, $connectionId, '2026-09-01', '2026-09-30');
// Each event needs happenedAt in epoch ms and an email or a clickId; the API hashes the address.
$client->ads()->sendConversionEvents($ruleId, $workspaceId, $connectionId, $events);

$page = $client->ads()->adLibrary($workspaceId, $connectionId, keyword: 'crm', countries: ['US']);
```

### Pixels, the Conversions API and custom conversions
Expand Down Expand Up @@ -715,7 +681,7 @@ $reach = $client->ads()->estimateReach($workspaceId, $connectionId, 'act_123', '
]);

// any campaign, ad set or ad by Meta id; breakdown is age, gender, placement or country
$report = $client->ads()->insights($connectionId, $campaign->id, '2026-09-01', '2026-09-07', breakdown: 'age', daily: true);
$report = $client->ads()->insights($connectionId, $campaignId, '2026-09-01', '2026-09-07', breakdown: 'age', daily: true);
$report = $client->ads()->adInsights($boost->id, $workspaceId, '2026-09-01', '2026-09-07'); // a FoPost ad id
```

Expand All @@ -736,27 +702,12 @@ while ($page->nextCursor !== null) {
$client->ads()->unsubscribeLeadPage('555', $workspaceId, $connectionId);
```

Catalogs, predictions and the public archive:
Goals and predictions:

```php
// Ask the connection what it can run, rather than assuming.
$goals = $client->ads()->goals($connectionId, $workspaceId);

// A catalog with a product set is what a catalog ad runs from.
$catalog = $client->ads()->createCatalog($workspaceId, $connectionId, 'Shop');
$client->ads()->writeCatalogProducts($catalog->id, $workspaceId, $connectionId, [
[
'op' => 'upsert',
'retailerId' => 'SKU-1042',
'name' => 'Trail Runner',
'url' => 'https://yourbrand.com/shop/trail-runner',
'imageUrl' => 'https://yourbrand.com/img/trail-runner.jpg',
'priceMinor' => 12900,
'currency' => 'USD',
],
]);
$set = $client->ads()->createProductSet($catalog->id, $workspaceId, $connectionId, 'Best sellers');

// Price a flight before buying it.
$prediction = $client->ads()->createReachFrequency(
$workspaceId,
Expand All @@ -770,9 +721,6 @@ $prediction = $client->ads()->createReachFrequency(
'2026-10-08T00:00:00Z',
);
$client->ads()->reserveReachFrequency($prediction->id, $workspaceId, $connectionId, 'act_1234567890');

// What anyone is running, read live and stored nowhere.
$archive = $client->ads()->library($connectionId, ['US'], $workspaceId, q: 'running shoes');
```

## Media
Expand Down Expand Up @@ -1217,24 +1165,21 @@ MIT. Copyright Porter Bridge, LLC.

### Google Ads

Campaigns, ad groups, ads, audiences and insights are on `$client->ads()` and dispatch by
connection. What only Google has is under `$client->ads()->google()`:
Audiences and insights are on `$client->ads()` and dispatch by connection. What only Google
has is under `$client->ads()->google()`:

```php
$keywords = $client->ads()->google()->keywords('c4d5e6f7-…', '1234567890');
$strategies = $client->ads()->google()->bidStrategies('c4d5e6f7-…', '1234567890');

$client->ads()->google()->createKeyword(
$client->ads()->google()->setAdSchedule(
workspaceId: '7d2b8c11-…',
connectionId: 'c4d5e6f7-…',
customerId: '1234567890',
adGroupId: '1234567890~adGroup~77',
text: 'running shoes',
matchType: 'EXACT',
campaignId: '1234567890~campaign~55',
slots: [['dayOfWeek' => 'MONDAY', 'startHour' => 9, 'endHour' => 18]],
);
```

Also `keywordIdeas()`, `keywordMetrics()`, `searchTerms()`, `bidStrategies()`,
`adSchedule()` and `setAdSchedule()`, the negative keyword lists, `assets()` and
`assetGroups()`, `localServicesLeads()`, the conversion methods, and `query()` for a raw
read-only GAQL SELECT. Changes need the `publish` scope as well as `ads`; the customer id
has to name an account the connection's grant reaches.
Also `createBidStrategy()`, `adSchedule()`, `localServicesLeads()`, the conversion methods,
and `query()` for a raw read-only GAQL SELECT. Changes need the `publish` scope as well as
`ads`; the customer id has to name an account the connection's grant reaches.
33 changes: 0 additions & 33 deletions src/Model/AdAccountTree.php

This file was deleted.

46 changes: 0 additions & 46 deletions src/Model/AdCampaign.php

This file was deleted.

44 changes: 0 additions & 44 deletions src/Model/AdCreative.php

This file was deleted.

61 changes: 0 additions & 61 deletions src/Model/AdLibraryEntry.php

This file was deleted.

Loading
Loading