コード例 #1
0
function send_task()
{
    require_once '../../../wp-load.php';
    include_once 'MyDataBase.php';
    global $wpdb;
    // Get the secrete code from the database
    // $config_table = new MyDataBase('sms_config');
    // $result = (array)$config_table->get_by(array('conf_type' => 'Secret'))[0];
    // $Secret_Code = $result['conf_value'];
    $Secret_Code = '123456';
    if (isset($_GET['task']) and $_GET['task'] == 'send') {
        $msgs = array();
        $message_table = new MyDataBase('messages');
        // connect to a table that contains messages to be sent
        $Pending_Messages = $result = (array) $message_table->get_by(array('pending' => 1, 'incoming' => 0));
        foreach ($Pending_Messages as $msg) {
            $the_msg = (array) $msg;
            $Current_Time = date("m-d-y G:i:s");
            if (strtotime($the_msg['expire_date']) > $Current_Time) {
                array_push($msgs, ["to" => $the_msg['sent_to'], "message" => $the_msg['message'], "uuid" => $the_msg['message_id']]);
            }
            //delete all pending messages after sending to SMSSync
            $message_table->update(array('pending' => 0), array('message_id' => $the_msg['message_id']));
        }
        // Send JSON response back to SMSsync
        $response = json_encode(["payload" => ["success" => true, "task" => "send", "secret" => $Secret_Code, "messages" => array_values($msgs)]]);
        write_message_to_file($response);
        send_response($response);
    }
}
コード例 #2
0
<?php

require_once '../../../wp-load.php';
include_once 'MyDataBase.php';
global $wpdb;
$message_id = "BENGEPOS";
$message_table = new MyDataBase('messages');
$message_table->insert(array('message_id' => $message_id, 'device_id' => $message_id, 'deleted' => $message_id, 'ms_from' => $message_id, 'message' => $message_id, 'sent_to' => $message_id, 'pending' => $message_id, 'expire_date' => $message_id, 'incoming' => $message_id, 'created_by' => $message_id, 'updated_by' => $message_id, 'update_date' => $message_id, 'sent_timestamp' => $message_id));
$response = json_encode(["payload" => ["success" => false, "error" => false]]);
コード例 #3
0
require_once '../../../wp-load.php';
include_once 'MyDataBase.php';
global $wpdb;
if (isset($_POST) && isset($_POST['Send'])) {
    $message_id = '12121';
    $device_id = '22';
    $deleted = '0';
    $msg_from = $_POST['msg_from'];
    $message = $_POST['msg_body'];
    $message_to = $_POST['msg_to'];
    $pending = '1';
    $expire_date = date("Y-m-d h:m:s", time());
    $incoming = '0';
    $created_by = '0';
    $updated_by = '0';
    $update_date = date("Y-m-d h:m:s", time());
    $sent_timestamp = date("Y-m-d h:m:s", time());
    //write_message_to_file(json_encode($update_date));
    $message_table = new MyDataBase('messages');
    $message_table->insert(array('message_id' => $message_id, 'device_id' => $device_id, 'deleted' => $deleted, 'ms_from' => $msg_from, 'message' => $message, 'sent_to' => $message_to, 'pending' => $pending, 'expire_date' => $expire_date, 'incoming' => $incoming, 'created_by' => $created_by, 'updated_by' => $updated_by, 'update_date' => $update_date, 'sent_timestamp' => $sent_timestamp));
    $response = json_encode(["payload" => ["success" => true, "error" => false]]);
    print_r($response);
}
?>
<form method="post" action="">
    Phone:<input type="text" name="msg_to"><br>
    Msg_Body:<input type="text" name="msg_body" value="This is message body"><br>
    Msg_From:<input type="text" name="msg_from" value="0916417951"><br>
    <input type="submit" name="Send" value="Send">
</form>