Reinaldo
Reinaldo

Reputation: 131

Can I access Facebook Ads archive using RestFB?

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

Upvotes: 0

Views: 434

Answers (2)

xcsob
xcsob

Reputation: 925

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

Upvotes: 0

Norbert
Norbert

Reputation: 1462

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.

Upvotes: 1

Related Questions