Announcement Announcement Module
Collapse
No announcement yet.
how to retrive a list of fan pages for oauthed user on facebook Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to retrive a list of fan pages for oauthed user on facebook

    hi,

    in our app we already oauthed a user and facebook returns back to our controller and we save the access token for later usage. At this point we wanted to call the graph api (from spring controller and not browser) and ask for a list of fan pages this user is part of. What's a good way to go about this. I know the current Facebook template does not provide anything for this... should we just do a custom template and call this url
    https://graph.facebook.com/myUserId/...ken=oauthToken

    Rest api from spring controller to get the list and parse the json to get fan page id,name.

    Any advice/suggestions?

  • #2
    Have you reviewed the latest capabilities of the FacebookApi on github for the upcoming M3 release?

    Comment


    • #3
      thanks but i figured it out.. just had to add a new call to facebooktemplate of our own that used graph api but asked for accounts

      Comment


      • #4
        What I did (and don't like it) in such situation

        FacebookTemplate (and FacebookApi):

        PHP Code:
        public List<Map<StringString>> getAccounts()
        {
          
        ResponseEntity<Mapresponse restTemplate.getForEntity(CONNECTION_URLMap.class, CURRENT_USER_ID"accounts");
          
        Map<String, List<Map<StringString>>> resultsMap response.getBody();
          List<
        Map<StringString>> accounts resultsMap.get("data");
          return 
        accounts;

        Then in Controller:

        PHP Code:
        List<Map<StringString>> accounts facebook.getAccounts();
                
        String accessToken null;
        for(
        Map<StringStringaccounts)
        {
          if (
        a.get("name").equals("MyPage"))
            
        accessToken a.get("access_token");
        }
        FacebookTemplate facebookTemplate = new FacebookTemplate(accessToken);
                
        LinkedMultiValueMap<StringStringmap = new LinkedMultiValueMap<StringString>();
        map.add("message"text);
        facebookTemplate.publish("me""feed"map); 

        But it's more like a hack, not solution.

        Any ideas where to put those "accounts" into spring-social infrastructure?

        Comment

        Working...
        X