"authenticator", "action" => 0 ]); $nonce_data = json_decode($nonce_response, true); $nonce = $nonce_data['nonce'] ?? null; if (!$nonce) { echo "Error: Failed to get nonce\n"; exit(1); } // 2. Login (Silent) $digest = md5("$password:$nonce"); $login_response = curl_request("http://$host/cgi-bin/auth_cgi", [ "module" => "authenticator", "action" => 1, "digest" => $digest ]); $login_data = json_decode($login_response, true); $token = $login_data['token'] ?? null; if (!$token) { echo "Error: Login failed - check password\n"; exit(1); } // 3. Fetch SMS $sms_response = curl_request("http://$host/cgi-bin/web_cgi", [ "token" => $token, "module" => "message", "action" => 2, "pageNumber" => 1, "amountPerPage" => 8, "box" => 0 ]); // DEBUGGING: Output the raw SMS response for inspection echo "
Raw SMS Response: " . htmlspecialchars($sms_response) . "
"; $sms_data = json_decode($sms_response, true); // DEBUGGING: Output the parsed JSON for inspection echo "
Parsed SMS Data: ";
print_r($sms_data);
echo "
"; $sms_list = $sms_data['messageList'] ?? []; $total_messages = $sms_data['totalNumber'] ?? 0; // HTML Structure echo " M7350 SMS Parser

M7350 SMS Reader

Initializing...
"; if ($sms_list) { echo "
Success: $total_messages messages found.
"; foreach ($sms_list as $sms) { $from = htmlspecialchars($sms['from']); $date = htmlspecialchars($sms['receivedTime']); $content = nl2br(htmlspecialchars($sms['content'])); $unread = isset($sms['unread']) && $sms['unread'] ? 'NEW' : ''; echo "
$unread
From: $from
Date: $date
$content
"; } } else { echo "
Inbox is empty.
"; } echo ""; ?>