Results 1 to 4 of 4

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

  1. #1
    Join Date
    Apr 2011
    Posts
    15

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Have you reviewed the latest capabilities of the FacebookApi on github for the upcoming M3 release?
    Keith Donald
    Core Spring Development Team

  3. #3
    Join Date
    Apr 2011
    Posts
    15

    Default

    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

  4. #4
    Join Date
    Jan 2009
    Posts
    1

    Default

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •