2

Trying to retrieve all marketing accounts of a Facebook business account using the spring social framework for Facebook .

  1. I want to know if there is any better way to it other than what i did below ?
  2. Does what i did for paging the query result is the right way to do it ?
  3. Is there another way to retrieve data from the Facebook Marketing API ?


I really appreciate any help you can provide.

public List<String> getListAdAccountsId(String businessAccountId) {
    final List<String> accountsId = new ArrayList<String>();
    final MultiValueMap<String, String> queryParameters = new LinkedMultiValueMap<String, String>();
    queryParameters.add("fields", "account_id");
    queryParameters.add("offset", "0");
    PagedList<Map> pagedResultSubSet = facebook.fetchConnections(businessAccountId, "adaccounts", Map.class,
            queryParameters);
    do {
        queryParameters.set("offset", pagedResultSubSet.getNextPage().getOffset().toString());
        pagedResultSubSet = facebook.fetchConnections(businessAccountId, "adaccounts", Map.class, queryParameters);
        accountsId.addAll(pagedResultSubSet.parallelStream().map(e -> e.get("id").toString())
                .collect(Collectors.toList()));
    } while (pagedResultSubSet.getNextPage() != null);

    return accountsId;
}
  • Have you read through guide to make sure you have set it up properly? What is the error you are getting? What happens when you retrieve it the way described above? – lamdadj22 Jun 16 '15 at 00:52

0 Answers0