2

I'm creating a management that finds impressions, clicks, and leads for Facebook campaigns associated with my business account. For impressions and clicks, there were no problems but I can not find the leads. This is the code (taken from Facebook Developer) of the function that tries to calculate the lead of each ad linked to the Facebook campaign. The values printed by the System Out are:

SIZE: 0, LIST: []

public void getTotalLeads(Campaign campaignFB) throws APIException {

    APINodeList<Ad> ads = campaignFB.getAds().execute();

    for (Ad ad : ads) {

        Ad adFb = new Ad(ad.getId(), context);

        APINodeList<Lead> listLeads = adFb.getLeads().execute(); 

        System.out.println("SIZE: " + listLeads.size());
        System.out.println("LIST: " + listLeads);        
    }
}

1 Answers1

0

in my case the ads were of the form type:

try {
     final AdAccount account = new AdAccount(ACCOUNT_ID, context);
     final APINodeList<LeadgenForm> forms = account.getLeadGenForms().execute();
     for (final LeadgenForm leadgenForm : forms) {
        System.out.println(leadgenForm.getId());
        final APINodeList<Lead> leads = leadgenForm.getLeads().execute();
        for (final Lead lead : leads) {
           System.out.println(lead.getFieldFieldData());
        }
     }
  }
  catch (final APIException e) {
     e.printStackTrace();
  }