0

My website is relaying heavily on FB. There is only FB login and all comunication with members happens through facebook. Users are notified using FB api about activities in site that they would care about. Users can choose between three options:

  1. Never notify
  2. Notify once a day(for MVP version I am good with hardcoded time, lets say, 9 in moorning, but probably aiming for possability for user to choose when they want to be notified about everything that has happened in last 24h)
  3. Notify on-the-go

First and third are easy, my concerns lies on second option. Basically its similar to newsletter. Here is my idea of this process so far:

  • When ever some action that is of concern for user happens, notification about that is saved in database
  • if user logs into site before scheduled time notification is marked as read
  • if user does not log into site before scheduled time unread notifications will be included in cron job
  • every hour cron job is run. It matches the users time zone with current time so that only only users that are awake will recive notification. Users will get basic "there are new things in site" notification.

Problem: From FB I can get only offset as integer, not actual timezone. I have spent some time on reading about timezone and different formats and it strikes me that FB call to get timezone results in offset.

Sending newletter(notification in my case) to different time zones is complex but there are a lot of good resource available. However it seems that best way to do that is save user time zone as TZ database format America/New_York. So my question is dual

  1. Is it possible to somehow get user time zone in TZ from facebook?
  2. If not, what would be my best actions? Whats important is that I dont care if user dont get notification at exact time. With that I mean that I dont care about summer time difference. it would be ok if user could chose between moorning, afternoon and evening(and if for example he chooses moorning, then he would get notification 9:00 +/- 1 hour). I am open to ideas, at given point my main consern is to get MVP running.
Kārlis Janisels
  • 1,265
  • 3
  • 18
  • 41

1 Answers1

0
$ch = curl_init("https://graph.facebook.com/v2.6/" . $user_id . "?fields=timezone&access_token=" . $fb_access_token);
curl_setopt_array($ch, array(
    CURLOPT_RETURNTRANSFER => 1
));

$result = curl_exec($ch);

You can get the user timezone from the open graph api.

For converting the offset to an actual timezone see the answer here: Convert UTC offset to timezone or date

Community
  • 1
  • 1
Ryan Tuosto
  • 1,941
  • 15
  • 23