studentgirl
studentgirl

Reputation: 15

How to get last updated Facebook ads

How do you only retrieve the "last" updated ads/adsets/campaigns from Facebook via the Ads API? I mean that I need to update on my database only those campaigns/adsets/ads that have changes, not all of them. I've found that a good technique is via facebook etag, but is there any other technique for this?

Upvotes: 0

Views: 561

Answers (1)

ikkuh
ikkuh

Reputation: 4603

You can use the filtering parameter to filter campaigns, adsets and ads on the updated_time field.

filtering=[{field: "<object>.updated_time", operator: "GREATER_THAN", value: <unix time>}]

Using the most recent unix time you have saved of the objects you can get all the more recently updated objects. A full curl version to get all campaigns updated after 2018-02-01:

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: I could only get unix time to work and have no idea if there is another format that is supported by the API

Upvotes: 2

Related Questions