Can I access Facebook Ads archive using RestFB?

195 views Asked by At

If using Facebook's graph explorer, I could do https://graph.facebook.com/v14.0/ads_archive followed by the access token and search parameters, and it returns the ads posted by pages in a given country? Can I do the same type of query using RestFB? Thanks

2

There are 2 answers

0
Norbert On

Maybe you have to use the JsonObject as return value, but in general: yes:

FacebookClient facebookClient = new DefaultFacebookClient("access token", Version.VERSION_14_0);
JsonObject return = facebookClient.fetchObject("ads_archive", JsonObject.class, Parameter.with("search query parameter", "search query value"));

The access token is added automatically to the request, and you have only to provide the search parameters. If you have more than one parameter, just add them. A parameter list can be handeled by the fetchObject method.

If the result is a connection (the Facebook version of a page-able list) use fetchConnection instead of fetchObject. RestFB takes care of the paging.

0
xcsob On

Is this API still valid? On the documentation I see that now the only ad_type supported is POLITICAL_AND_ISSUE_ADS.

https://business.facebook.com/ads/library/api/?source=archive-landing-page