protected function run_action()

in core/ServerEventAsyncTask.php [128:152]


  protected function run_action() {
    try {
      $num_events = $_POST['num_events'];
      if( $num_events == 0 ){
        return;
      }
      // $_POST['event_data'] is decoded from base 64, returning a JSON string
      // and decoded as a php array
      $events_as_array = json_decode(base64_decode($_POST['event_data']), true);
      // If the passed json string is invalid, no processing is done
      if(!$events_as_array){
        return;
      }
      $events = array();
      // Every event is a php array and casted to an Event object
      foreach( $events_as_array as $event_as_array ){
        $event = $this->convert_array_to_event($event_as_array);
        $events[] = $event;
      }
      FacebookServerSideEvent::send($events);
    }
    catch (\Exception $ex) {
      error_log($ex);
    }
  }