Announcement Announcement Module
Collapse
No announcement yet.
Facebook profile - get user's birthday in common format Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Facebook profile - get user's birthday in common format

    hey,

    I need to get the user's birthday from facebook. I have a serious problem with it.

    PHP Code:
            FacebookProfile profile f.userOperations().getUserProfile();
            
    String birthday profile.getBirthday(); 
    About this birthday facebook tells us: "The format of this date varies based on the user's locale.".
    This is the birthday which is mapped to the value object of spring social.

    However there is an other one birthday_date which is "The birthday of the user being queried in MM/DD/YYYY format". The latter one would be a lot easier to parse I guess. I cannot find it mapped anywhere in spring social, unfortunately.

    You would think it's still possible to parse a date because the Locale of the user is also available. However I noticed (checked a few times) that inspite of the fact that my Locale was en_GB, facebook returned my DOB in US-style middle-endian format (as you would expect with birthday_date). Strange.

    So my question is, is it possible somehow to retrieve the birthday_date? Do you plan to map the birthday String to a java Date maybe?

    Thank you for the answer,
    Balázs

  • #2
    It seems that the birthday_date is not available on the User object returned from the Graph API. It may have been available in Facebook's old REST API and it is available in the user table using FQL. The getUserProfile() method fetches from the Graph API, so that isn't available unless I were to turn around and do FQL to get the birthday.

    So, here are the choices:
    - Change getUserProfile() to do both...fetch most of the profile from the Graph API and then do FQL to get the birthday_date. This isn't desirable because it would be inefficient, especially for those apps who won't even use the birthday_date.
    - Change getUserProfile() to do only FQL. Possible, but I'd rather not rely on FQL for most API binding methods.
    - Change getUserProfile() to do the conversion of birthday to a java.util.Date for you (handling any locale-specific problems in the process). This is the most desirable option, although it may be a bit tricky. I'll look into it.
    - You can do the FQL yourself to get the birthday_date if you want. The latest Spring Social Facebook 1.1.0.BUILD-SNAPSHOT builds have support for FQL via the Facebook.fqlOperations() method. This will give you the most immediate option, although will require more work on your part.

    I do tend to agree that fetching the birthday as a Date is a nice thing and I'll look into making it possible. In the meantime, doing your own FQL should work.

    Comment


    • #3
      Thank you for your answer.

      Apparently I was wrong. The reason of my confusion was that I was looking at the FQL API and not the User Object which in fact always returns a middle-endian formatted date, so the "birthday" in the User object is in fact the "birthday_date" and not the "birthday", which is rather strange (if it only was the first by facebook) but at least we can work with that

      But as I said to return a Date object would be desirable since parsing a String is a level lower than you would like to work on. And unfortunately I cannot rely on snapshot releases, so I have to wait for a full release then :S

      Comment

      Working...
      X