insert() public method

public insert ( )
Esempio n. 1
0
 /**
  * Handles Mandrill inbound web hook
  *
  * @return void
  */
 public function handle_post()
 {
     if (isset($_POST['mandrill_events'])) {
         $parsed = reset(json_decode(wp_unslash($_POST['mandrill_events'])));
         if (!$parsed) {
             return;
         }
         $reply = new Falcon_Reply();
         $reply->subject = $parsed->msg->subject;
         $reply->body = $parsed->msg->text;
         list($reply->post, $reply->site, $reply->user, $reply->nonce) = Falcon_Reply::parse_to($parsed->msg->email);
         $reply_id = $reply->insert();
         if ($reply_id === false) {
             header('X-Fail: No reply ID', true, 400);
             echo 'Reply could not be added?';
             // intentionally not translated
             // Log this?
         }
     }
 }
Esempio n. 2
0
 public function handle_post()
 {
     $input = file_get_contents('php://input');
     if (empty($input)) {
         header('X-Fail: No input', true, 400);
         echo 'No input found.';
         // intentionally not translated
         return;
     }
     file_put_contents('/tmp/postmark', $input);
     try {
         $inbound = new \Postmark\Inbound($input);
     } catch (\Postmark\InboundException $e) {
         header('X-Fail: Postmark problem', true, 400);
         echo $e->getMessage();
         return;
     }
     // The "Test" button sends an email from support@postmarkapp.com
     if ($inbound->FromEmail() === '*****@*****.**') {
         echo 'Hello tester!';
         // intentionally not translated
         return;
     }
     $reply = new Falcon_Reply();
     $reply->subject = $inbound->Subject();
     $reply->body = $inbound->TextBody();
     $to = $inbound->Recipients();
     list($reply->post, $reply->site, $reply->user, $reply->nonce) = Falcon_Reply::parse_to($to[0]->Email);
     $reply_id = $reply->insert();
     if ($reply_id === false) {
         header('X-Fail: No reply ID', true, 400);
         echo 'Reply could not be added?';
         // intentionally not translated
         // Log this?
     }
 }