Announcement Announcement Module
Collapse
No announcement yet.
Facebook API Question Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Facebook API Question

    Is there any way i can get a list of pages a user administers?

  • #2
    No, but that sounds like a useful addition to the API binding. It should be simple to get a list of page IDs for the pages the user administers. Getting a list of Page objects may be a bit more tricky, but still might be possible.

    Please open an issue in JIRA for this. Or, if you want to try implementing it, then give it a go and submit a pull request.

    Comment


    • #3
      I saw that all of the classes in Impl (AccountList, GroupList etc) are scoped to default (i guess private package). Because of this i cannot use fetchConnection method in FacebookTemplate to actually get a list of Accounts (Which will list the pages for me) using the below code in my class:

      List<Account> userPages = facebookConnection.getApi().fetchConnections(provi derUserId, "accounts", AccountList.class , null);

      Is there any reason you guys scoped it to default?

      Also is spring-social-facebook not a maven project? (In the sense cant i use maven to build it?)
      Last edited by ppnyc; Jun 29th, 2011, 08:49 AM.

      Comment


      • #4
        The stuff in impl is not considered part of the public API. AccountList, GroupList, etc are just container classes to help with the JSON deserialization. It's not those types that should be exposed in the API, but the list returned from their getList() methods.

        In PageTemplate, fetchConnections() is used to fetch a list of Account objects already. Those aren't exposed through the API, although with a little bit of rework they could be. But it should be a List<Account> returned, not AccountList.

        Comment


        • #5
          This is my observation, may be i am missing something here.

          By scoping the classes in Impl package-private, you have removed a lot of flexibility. For example now if need to get a list of accounts, i am bound to the methods offered by the interface.

          Now to get around this, I created a class called AccountList which is an exact copy of AccountList class in impl package of spring social facebook. Then to make the call to get a list of Accounts i did this:

          List<Account> userPages = facebookConnection.getApi().fetchConnections("me", "accounts", AccountList.class).getList();

          If the AccountList class in Impl was public i could have used that instead of needlessly creating a new one.

          Anyway now i am able to fetch the list of accounts that a user administers.
          I had to create a copy of of AccountList in

          Comment


          • #6
            I'm in the same boat, and agree that this should be exposed. fetchConnections would imply a List is returned, so why not type it as a List<T> based on the type passed? It would require some work in the implementation to go from the singular to the plural (Account uses AccountList, etc.) but makes the most since from a developer's perspective (mine).

            Comment


            • #7
              AccountList and the various List subclasses are workarounds for the fact that parameterized type information cannot be provided in any other way when working with the RestTemplate API. This is unfortunate, and leads to a proliferation of such subclasses. The fact we consider this a workaround is why we've strictly kept these types package-private thus far.

              What seems clear is we need the ability to instruct the REST client to map a JSON array result to a typed List. We should explore if this can be done without requiring an ArrayList subclass to be defined each time this kind of mapping is needed. We should also re-evaluate the Facebook GraphApi fetchConnections signature, as suggested by Nick.

              Keith
              Last edited by Keith Donald; Jul 4th, 2011, 11:27 AM.

              Comment


              • #8
                I see what you're saying....as it is, fetchConnections() isn't much use in the public API without either exposing those list wrapper types or forcing you to recreate them yourselves (neither of which is ideal). Moreover, Nick makes a good point that fetchConnections() could be more intuitive if it was given the type of element returned in the list instead of the type of element it returns.

                I've created https://jira.springsource.org/browse/SOCIAL-218 to track this. The work I've done so far on this looks promising--it eliminates the need for the wrapper types altogether and enables you to do something like this:

                Code:
                List<Account> facebookTemplate.fetchConnections("me", "accounts", Account.class);
                I'll let you know when it's ready in a snapshot build.

                Comment


                • #9
                  I just pushed a snapshot build that I think will address the concerns expressed in this thread. Externally, the only changes are (1) the fetchConnections() signature has changed to return List<T> instead of T. Internally, I've done away with the wrapper types in favor of handling a small amount of the parsing within FacebookTemplate (just enough to get to the "data" element of the returned JSON).

                  Try it out and let me know if it works for you. Thanks!

                  Comment


                  • #10
                    Glad to hear it! I'll check it out when/if I get a chance, and am looking forward to its release.

                    Comment


                    • #11
                      Thanks guys!! This is awesome!!

                      Comment


                      • #12
                        The original request seems to have been hijacked in this thread. Back to the original request, is there a way to get a list of pages? In PageOperations (PageTemplate), there is a public Page getPage(String pageId) and a public List<Account> getAccounts(), but not a public List<Page> getPages(). Can that be added to the API? I was going to try to implement it myself, but I couldn't extend PageTemplate because the class is not public. Can you make the class public, so we can extend it as needed? Many thanks.

                        Comment


                        • #13
                          I suppose that it could be added to the API binding, but what endpoint on Facebook's Graph API would you use?

                          Comment

                          Working...
                          X