Example #1
0
// + STEP 2: get data				   +
// +-----------------------------------+
$token = $_REQUEST['access_token'];
$other_id = $_REQUEST['user2'];
$message = $_REQUEST['message'];
if (!($token && $other_id && $message)) {
    $success = "0";
    $msg = "Incomplete Parameters";
    $data = array();
} else {
    // +-----------------------------------+
    // + STEP 3: perform operations		   +
    // +-----------------------------------+
    $user_id = GeneralFunctions::getUserId($token);
    if ($user_id) {
        $data = Messages::saveUserMessage($user_id, $other_id, $message);
        if ($data) {
            $success = "1";
            $msg = "Message Sent";
        }
    } else {
        $success = "0";
        $msg = "Token Expired";
    }
}
// +-----------------------------------+
// + STEP 4: send json data		    +
// +-----------------------------------+
/*if($success==1){
echo json_encode(array("success"=>$success,"msg"=>$msg,"message"=>$message));
}
Example #2
0
     $randomFileName = randomFileNameGenerator("Img_") . "." . end(explode(".", $image['name']));
     if (@move_uploaded_file($image['tmp_name'], "../uploads/{$randomFileName}")) {
         $image_name = $randomFileName;
     }
 } else {
     $image_name = "";
 }
 if ($video) {
     $randomFileName1 = randomFileNameGenerator("Img_") . "." . end(explode(".", $video['name']));
     if (@move_uploaded_file($video['tmp_name'], "../uploads/{$randomFileName1}")) {
         $video_name = $randomFileName1;
     }
 } else {
     $video_name = "";
 }
 $data = Messages::saveUserMessage($user_id, $other_id, $message, $image_name, $video_name, $message_type);
 if ($data) {
     $success = "1";
     $msg = "Message Sent";
     $messages = Messages::getRecUserMessagesAfter($user_id, $other_id, $message_id);
     $data = $messages ? $messages : [];
     //push check
     $push_check = GeneralFunctions::PushCheck($other_id);
     $push_notif = $push_check[0]['push_notification'];
     if ($push_notif) {
         //push notification code
         $user = GeneralFunctions::get_push_ids($other_id);
         $apnid = $user[0]['apn_id'];
         $oid = $user[0]['id'];
         $reg_ids[] = $user[0]['reg_id'];
         $message = array();