} $tmp[$key] = $val; } if (count($tmp) === 1) { $tmp[] = array_shift($tmp); } $data = array('returnCode' => 'SUCCESS', 'notifications' => $tmp, 'unseen_count' => $unseen_count, 'lni' => $lni); echo json_encode($data); break; case 'setLastNotificationId': $id = $_POST['id']; if ((int) $id) { $lastNotificationId = getLastNotificationId(); $username = $_SESSION['user_name']; $lastNotificationId[$username] = $_POST['id']; MultiCache::cache_set('lastNotificationId', $lastNotificationId, 60 * 60 * 24 * 7); $data = array('returnCode' => 'SUCCESS'); } else { $data = array('returnCode' => 'FAIL', 'error' => 'Invalid notification ID.'); } echo json_encode($data); break; // case "addUserQueue": // case "addUserQueue": case "addUserQueue": $payload = array_to_xml($_POST['data']); $request = simplexml_load_string('<request>' . $payload . '</request>'); $saved = $api->addUserQueue($request); echo json_encode($saved); break; // case "addSavedUrls":