def monitor_users(self, app_id, users, message, time_to_post=None): for user in users: online_presence = check_online_presence(user) if online_presence is None: online_presence = "error" #cannot determine online presence monitor_user = MonitoredUser(app_id=app_id, id=user.id, last_online_presence=online_presence, message=message, access_token=user.access_token, time_to_post=time_to_post) monitor_user.put()
def get(self): monitored_users = MonitoredUser.all() for user in monitored_users: message = user.message access_token = user.access_token current_online_status = check_online_presence(user) if (current_online_status == 'active' ): #active, idle, offline, or error graph = facebook.GraphAPI(access_token) if user.time_to_post: now = datetime.datetime.now() if now > user.time_to_post: graph.put_wall_post(message=message, profile_id=user.id) user.delete( ) #remove this user's pending post from the cron list logging.debug( "Online presence + scheduled posting User ID " + user.id + " | Message: " + message) else: graph.put_wall_post(message=message, profile_id=user.id) logging.debug("Online posting User ID " + user.id + " | Message: " + message) user.delete( ) #remove this user's pending post from the cron list
def get(self): monitored_users = MonitoredUser.all() for user in monitored_users: message = user.message access_token = user.access_token current_online_status = check_online_presence(user) if (current_online_status == 'active'): #active, idle, offline, or error graph = facebook.GraphAPI(access_token) if user.time_to_post: now = datetime.datetime.now() if now > user.time_to_post: graph.put_wall_post(message=message, profile_id=user.id) user.delete() #remove this user's pending post from the cron list logging.debug("Online presence + scheduled posting User ID " + user.id + " | Message: " + message) else: graph.put_wall_post(message=message, profile_id=user.id) logging.debug("Online posting User ID " + user.id + " | Message: " + message) user.delete() #remove this user's pending post from the cron list