Currently all facebook PageOperations depend on the "access_token" to be present. This abstraction is handled in the PageOperations template which introduces a private cache and getter for page access tokens. The problem arises that:
there is no easy way to add new PageOperations extending the existing ones
implementing the logic in someone's own code requires reimplementing the token cache since its private which makes it a bit redundant.
Places I am having trouble with:
For example PageOperations exposes the postPhoto(pageId, albumId, Resource) method, in order to use that one will have to first create an album in the given pageId. There doesn't seem to be a way to do that currently. MediaOperations.createAlbum creates it in the user's account and not under the page. There also doesn't seem to be an api to post directly to a page wall, which would seem like a much more common use case, then posting to an album (which can't be created programmatically currently). For example to post a photo to a page wall i have to write something like
Map<String, Account> accountCache = new HashMap<String, Account>();List<Account> accounts = facebook.pageOperations().getAccounts();
for (Account account : accounts) {
accountCache.put(account.getId(), account);
}
MultiValueMap<String, Object> parts = new LinkedMultiValueMap<String, Object>();
parts.set("source", imageResource);
parts.set("message", message);
parts.set("access_token", accountCache.get(facebookPageId).getAccessToken());
facebook.publish(facebookPageId, "photos", parts);
Notice that accountCache will be redundant. I read the API a few times, browsed over the code but didnt see a better way at doing it. What's your take on this?
Currently all facebook PageOperations depend on the "access_token" to be present. This abstraction is handled in the PageOperations template which introduces a private cache and getter for page access tokens. The problem arises that:
Places I am having trouble with: For example PageOperations exposes the postPhoto(pageId, albumId, Resource) method, in order to use that one will have to first create an album in the given pageId. There doesn't seem to be a way to do that currently. MediaOperations.createAlbum creates it in the user's account and not under the page. There also doesn't seem to be an api to post directly to a page wall, which would seem like a much more common use case, then posting to an album (which can't be created programmatically currently). For example to post a photo to a page wall i have to write something like
Notice that accountCache will be redundant. I read the API a few times, browsed over the code but didnt see a better way at doing it. What's your take on this?