0

I am using the Facebook PHP Business SDK to retrieve adsets that have an updated_time value in the past two weeks.

So far I have:

$adsets = $campaign->getAdsets(
    [AdSetFields::NAME, AdSetFields::UPDATED_TIME], // fields
    [AdSetFields::UPDATED_TIME => AdSetDatePresetValues::LAST_14D] // params
); 

The params part does not seem to have an effect on the data being returned. Appreciate any guidance.

1 Answer 1

0

I managed to find a solution:

The params parameter has to be in the following format:

    $currentDateTimeObj = new DateTime('now', new \DateTimeZone('Europe/London'));
    $fourteenDaysAgoDateTimeObj = $currentDateTimeObj->sub(new DateInterval('P14D'));

    $inactiveUpdatedCampaignsParams = [
        'filtering' => [
            ['field' =>  CampaignFields::EFFECTIVE_STATUS, 'operator' => 'NOT_IN',  'value' => ['ACTIVE']],
            ['field' => 'adset.updated_time', 'operator' => 'GREATER_THAN',  'value' => $fourteenDaysAgoDateTimeObj->getTimestamp()]
        ]
    ];

In the above example, when making the following Facebook API call $adAccount->getCampaigns($fields, $inactiveFutureCampaignsParams); it will return Campaigns that do not have a 'ACTIVE' effective status and has adsets that have an updated_time in the last two weeks.

Its a shame this isn't documented in the Facebook PHP Business SDK documentation.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.