i need to make an app that sends an email to the user on the user’s friend’s birthday..
i’m thinking about having an app that saves on DB the whole list of friend’s bday for each registered user and then have a cron job running on server each day that check for birthdays and send emails to each user that have 1 or more friend on that birthday event.
..or having just the cron job that retrieve the list of friend’s bday before sending the emails..
btw.. how to retrieve this bday list for each user?.. does open graph be any help?
..also, do you think there’s a better solution than the cronjob?
It’s simple enough, the User object in the graph API has a
birthdayattribute, you just need to make sure you request thefriends_birthdaypermission in the auth process. It’s an extended permission which the user can probably opt out of, so you’ll need some additional checks after the auth to make sure they allowed it with tha permission.My guess is that you’d need to do the birthday stuff in two steps, 1) get the friend list, 2) iterate through fetching birthdays (you could probably do this better with FQL and select multiple friends’ birthdays at once).
I would abstract the graph api stuff so it happens in workers on the server (take a look at Beanstalkd). You could also use Beanstalkd to handle sending emails as workers, but use Cron to queue them.