Notification texts go here Contact Us Buy Now!

How to get last updated Facebook ads

How to Get Last Updated Facebook Ads

To retrieve Facebook ads that have been updated recently, utilize the filtering parameter. Here's how to do it:

Filtering Parameter

The filtering parameter allows you to filter various ad objects (campaigns, ad sets, and ads) based on their updated_time field. The syntax for the filtering parameter is as follows:

filtering=[{field: "<object>.updated_time", operator: "GREATER_THAN", value: <unix time>}]
where: * <object> represents the ad object you want to filter (e.g., "campaign", "adset", or "ad") * GREATER_THAN is the comparison operator indicating that the updated time should be greater than the specified value * <unix time> is the Unix time (in seconds) representing the time after which you want to retrieve updated ads

Example: Get Campaigns Updated After a Specific Time

To fetch all campaigns updated after a specific Unix time (e.g., 2018-02-01), use the following cURL command:

curl -G \
-d 'access_token=<ACCESS_TOKEN>' \
-d 'filtering=[{field:"campaign.updated_time",operator:"GREATER_THAN",value:1517443200}]' \
'https://graph.facebook.com/v2.12/act_<ACCOUNT_ID>/campaigns'

Note:

In Python, you can use the GraphAPI.get_objects() method to retrieve ad objects with the filtering parameter.

For example, to filter ad sets updated in the last one day, you can use the following code:

import facebook
import datetime

graph = facebook.GraphAPI(access_token='YOUR_ACCESS_TOKEN')

params = {
    'filtering': [
        {
            'field': 'adset.updated_time',
            'operator': 'GREATER_THAN',
            'value': (datetime.datetime.now() - datetime.timedelta(days=1)).timestamp()
        }
    ]
}

adsets = graph.get_objects('act_YOUR_ACCOUNT_ID/adsets', fields='id,name,updated_time', **params)

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.