@צדיק-תמים
נכון מאוד
הסתדר!
עשיתי קוד להזנת מונה חשמל וחישוב לדאטה בייס;
<?php
// Sanitize and validate input
$ApiPhone = filter_input(INPUT_GET, 'ApiPhone', FILTER_SANITIZE_STRING);
if (!$ApiPhone) {
die("Invalid input");
}
$new_counter = filter_input(INPUT_GET, 'a', FILTER_VALIDATE_INT);
if (!$new_counter) {
die("Invalid input");
}
// Connect to the database
$db = new mysqli('localhost', '?', '?!', '?');
// Check for errors
if ($db->connect_error) {
die("Connection failed: " . $db->connect_error);
}
//the table name
$table = 'Electricity_meter';
// Prepare and execute the SQL query using a prepared statement
$sql = "SELECT `sum_counter`, `prev_data` FROM `$table` WHERE `ApiPhone` = ? ORDER BY `prev_data` DESC LIMIT 1";
$stmt = $db->prepare($sql);
if (!$stmt) {
die("Error preparing query: " . $db->error);
}
$stmt->bind_param("s", $ApiPhone); // bind the ApiPhone variable to the prepared statement
$stmt->execute();
$result = $stmt->get_result();
// Check for errors
if (!$result) {
die("Error executing query: " . $db->error);
}
// Fetch the results
$row = $result->fetch_assoc();
if (!$row) {
die("No results found");
}
// Perform the calculation
$result1 = 0;
if ($new_counter >= $row['sum_counter']) {
$result1 = ($new_counter - $row['sum_counter']) * 0.6155;
}
if ($result1 < 0) {
$result1 = 0;
}
// Calculate the number of days between the two dates
$prev_date = strtotime($row['prev_data']);
if (!$prev_date) {
die("Invalid date format");
}
$today = strtotime(date('Y-m-d'));
if (!$today) {
die("Invalid date format");
}
$num_days = floor(($today - $prev_date) / 86400);
// Calculate the result
$result2 = $num_days * 3.6;
$result3 = round($result1 + $result2, 2);
// Insert the new data into the table
$insert_sql = "INSERT INTO `$table` (`sum_counter`, `prev_data`, `sum_payment`, `ApiPhone` ) VALUES ('$new_counter', NOW(), '$result3', '$ApiPhone')";
$insert_result = $db->query($insert_sql);
if (!$insert_result) {
die("Error inserting data: " . $db->error);
}
// Close the database connection
$stmt->close();
$db->close();
// Print the result
echo "id_list_message=t-סך הכל שעליך לשלם.n-" . str_replace(".", ".t-נקודה.d-", $result3);
?>
אולם כאשר אני מפעיל את הקוד בשלוחת API, משום מה השרת מקבל פעמיים את ההפעלה, ומוזן לDB פעמיים נתונים (מה שמבלבל את הנתונים לפעם הבאה).
מישהו מכיר או למאןדהו פתרונים?
יש לי קו SIP בלגי, שממנה אני יכול לחייג חינם לבלגיה כאשר אני מגדיר אותו בmicroSIP וכדו'.
השאלה שלי האם ניתן להגדיר שלוחה במערכת כאילו שזה תכנת SIP עם שם משתמש ודומיין הsip, ולהוציא שיחות הימנה. [ולחלופין שהשלוחה תוציא אוטומטית שיחה למס' X דרך הSIP]
המרות ללא הגבלה, פלא א"כ מדוע ימות המשיח עצמם לא מספקים את השירות הזה,
וכי אין לזה צורך [לטקסטים באנגלית] ?!
עשיתי קוד להזנת מונה חשמל וחישוב לדאטה בייס;
<?php
// Sanitize and validate input
$ApiPhone = filter_input(INPUT_GET, 'ApiPhone', FILTER_SANITIZE_STRING);
if (!$ApiPhone) {
die("Invalid input");
}
$new_counter = filter_input(INPUT_GET, 'a', FILTER_VALIDATE_INT);
if (!$new_counter) {
die("Invalid input");
}
// Connect to the database
$db = new mysqli('localhost', '?', '?!', '?');
// Check for errors
if ($db->connect_error) {
die("Connection failed: " . $db->connect_error);
}
//the table name
$table = 'Electricity_meter';
// Prepare and execute the SQL query using a prepared statement
$sql = "SELECT `sum_counter`, `prev_data` FROM `$table` WHERE `ApiPhone` = ? ORDER BY `prev_data` DESC LIMIT 1";
$stmt = $db->prepare($sql);
if (!$stmt) {
die("Error preparing query: " . $db->error);
}
$stmt->bind_param("s", $ApiPhone); // bind the ApiPhone variable to the prepared statement
$stmt->execute();
$result = $stmt->get_result();
// Check for errors
if (!$result) {
die("Error executing query: " . $db->error);
}
// Fetch the results
$row = $result->fetch_assoc();
if (!$row) {
die("No results found");
}
// Perform the calculation
$result1 = 0;
if ($new_counter >= $row['sum_counter']) {
$result1 = ($new_counter - $row['sum_counter']) * 0.6155;
}
if ($result1 < 0) {
$result1 = 0;
}
// Calculate the number of days between the two dates
$prev_date = strtotime($row['prev_data']);
if (!$prev_date) {
die("Invalid date format");
}
$today = strtotime(date('Y-m-d'));
if (!$today) {
die("Invalid date format");
}
$num_days = floor(($today - $prev_date) / 86400);
// Calculate the result
$result2 = $num_days * 3.6;
$result3 = round($result1 + $result2, 2);
// Insert the new data into the table
$insert_sql = "INSERT INTO `$table` (`sum_counter`, `prev_data`, `sum_payment`, `ApiPhone` ) VALUES ('$new_counter', NOW(), '$result3', '$ApiPhone')";
$insert_result = $db->query($insert_sql);
if (!$insert_result) {
die("Error inserting data: " . $db->error);
}
// Close the database connection
$stmt->close();
$db->close();
// Print the result
echo "id_list_message=t-סך הכל שעליך לשלם.n-" . str_replace(".", ".t-נקודה.d-", $result3);
?>
אולם כאשר אני מפעיל את הקוד בשלוחת API, משום מה השרת מקבל פעמיים את ההפעלה, ומוזן לDB פעמיים נתונים (מה שמבלבל את הנתונים לפעם הבאה).
מישהו מכיר או למאןדהו פתרונים?
@Liy
יש אפשרות להשתמש בו בצורה של API?
המנוע דיבור TTS של עלמהרידר מקריאה טקסט באנגלית באופן "מעוברת" ולא רגיל, ישנו אפשרות להגדיר מנוע דיבור אחר המתאים לאנגלית?
@amp-Software-0
עכשיו אני קולט, שזה משנה את הסשן ID בכל שיחה חדשה (גם מאותו מספר), ורק באותה השיחה הסשן נשאר זהה. אז לא פתרנו את הבעיה. יש לך פתרון?
@amp-Software-0
תודה רבה!
עובד נפלא!!!!
@לעזור-לכולם
@amp-Software-0
ערכתי אתמול קוד להזנת מונה חשמל לשוכרי יחידה, והקראת העלות + מחיר קבוע יומי לגז~מים.
<?php
session_start();
// Check if the previous result is stored in the session
if (!isset($_SESSION['counter'])) {
$_SESSION['counter'] = 0;
}
// Check if the previous date is stored in the session
if (!isset($_SESSION['prev_date'])) {
$_SESSION['prev_date'] = strtotime(date('Y-m-d', strtotime('2023-1-1')));
}
// Get the number from the GET request
$number = (int) $_GET['a'];
// Perform the calculation
$result1 = ($number - $_SESSION['counter']) * 0.6155;
// Get today's date
$today = strtotime(date('Y-m-d'));
// Calculate the number of days between the two dates
$num_days = ($today - $_SESSION['prev_date']) / 86400;
// Calculate the result
$result2 = $num_days * 3.6;
// Calculate the second result
$result3 = $result2 + $result1;
// Update the previous date in the session
$_SESSION['prev_date'] = $today;
// Update the result in the session
$_SESSION['counter'] = $number;
// Update the result in the session
$_SESSION['amount'] = $result3;
// Log the current value of $_SESSION
$log_file = fopen('session_log.txt', 'a');
fwrite($log_file, print_r($_SESSION, true));
fclose($log_file);
// Print the result
print "id_list_message=t-סך הכל שעליך לשלם .n- $result3 .t-שקל, יש לבצע העברה בנקאית בהקדם:"
?>
אולם נתקלתי באותה הבעיה שדרך הטלפון זה מזוהה כסשן חדש כל פעם, למרות שבדפדפן זה פועל מצויין.
וכעת אני רואה שיש לך פתרון לזה.
מה אני אמור לשנות כאן שזה יעבוד?