@צבי-ד-צ @זאביק טוב בקשה מgpt זה מה שיצא תכניס את זה לשרת שלך, כמובן על אחריותך בלבד...
<?php
$success = '';
$error = '';
$transferredCount = 0;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$token = $_POST['token'];
$sourceTemplateId = $_POST['source_template'];
$targetTemplateId = $_POST['target_template'];
function apiRequest($url, $data) {
$curl = curl_init($url);
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => http_build_query($data),
]);
$response = curl_exec($curl);
curl_close($curl);
return json_decode($response, true);
}
// שליפת רשימת המספרים
$getUrl = 'https://www.call2all.co.il/ym/api/GetTemplateEntries';
$getResponse = apiRequest($getUrl, [
'token' => $token,
'templateId' => $sourceTemplateId,
]);
if (!isset($getResponse['entries'])) {
$error = "שגיאה בקבלת רשימת המספרים";
} else {
// ניקוי הרשימה הקיימת
$clearUrl = 'https://www.call2all.co.il/ym/api/ClearTemplateEntries';
apiRequest($clearUrl, [
'token' => $token,
'templateId' => $targetTemplateId,
]);
// הוספת המספרים החדשים
$updateUrl = 'https://www.call2all.co.il/ym/api/UpdateTemplateEntry';
foreach ($getResponse['entries'] as $entry) {
$res = apiRequest($updateUrl, [
'token' => $token,
'templateId' => $targetTemplateId,
'phone' => $entry['phone'],
'name' => $entry['name'] ?? '',
'moreinfo' => $entry['moreinfo'] ?? '',
'blocked' => $entry['blocked'] ? 1 : 0,
]);
$transferredCount++;
}
$success = "בוצעה העברה של $transferredCount מספרים בהצלחה.";
}
}
?>
<!DOCTYPE html>
<html lang="he">
<head>
<meta charset="UTF-8">
<title>העברת מספרים בין תבניות</title>
<style>
body { font-family: sans-serif; direction: rtl; padding: 20px; max-width: 600px; margin: auto; }
label { display: block; margin-top: 10px; }
input[type="text"], input[type="number"] { width: 100%; padding: 8px; margin-top: 5px; }
button { margin-top: 20px; padding: 10px 20px; font-size: 16px; }
.msg { margin-top: 20px; font-weight: bold; }
</style>
</head>
<body>
<h2>העברת מספרים בין רשימות תפוצה</h2>
<form method="post">
<label>Token:
<input type="text" name="token" required>
</label>
<label>מזהה תבנית מקור:
<input type="number" name="source_template" required>
</label>
<label>מזהה תבנית יעד:
<input type="number" name="target_template" required>
</label>
<button type="submit">העבר מספרים</button>
</form>
<?php if (!empty($error)): ?>
<div class="msg" style="color: red;"><?= htmlspecialchars($error) ?></div>
<?php elseif (!empty($success)): ?>
<div class="msg" style="color: green;"><?= htmlspecialchars($success) ?></div>
<?php endif; ?>
</body>
</html>