Create se_opr.html
Browse files- se_opr.html +122 -0
 
    	
        se_opr.html
    ADDED
    
    | 
         @@ -0,0 +1,122 @@ 
     | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
|
| 
         | 
| 
         | 
|
| 1 | 
         
            +
            <!DOCTYPE html>
         
     | 
| 2 | 
         
            +
            <html lang="en">
         
     | 
| 3 | 
         
            +
            <head>
         
     | 
| 4 | 
         
            +
                <meta charset="UTF-8">
         
     | 
| 5 | 
         
            +
                <meta name="viewport" content="width=device-width, initial-scale=1.0">
         
     | 
| 6 | 
         
            +
                <title>Send Poll to Group</title>
         
     | 
| 7 | 
         
            +
                <style>
         
     | 
| 8 | 
         
            +
                    body {
         
     | 
| 9 | 
         
            +
                        font-family: Arial, sans-serif;
         
     | 
| 10 | 
         
            +
                        text-align: center;
         
     | 
| 11 | 
         
            +
                        background-color: #f0f0f0;
         
     | 
| 12 | 
         
            +
                        margin: 0;
         
     | 
| 13 | 
         
            +
                        padding: 0;
         
     | 
| 14 | 
         
            +
                    }
         
     | 
| 15 | 
         
            +
                    h1 {
         
     | 
| 16 | 
         
            +
                        background-color: #4CAF50;
         
     | 
| 17 | 
         
            +
                        color: white;
         
     | 
| 18 | 
         
            +
                        padding: 20px;
         
     | 
| 19 | 
         
            +
                        margin: 0;
         
     | 
| 20 | 
         
            +
                        border-bottom: 2px solid #388E3C;
         
     | 
| 21 | 
         
            +
                    }
         
     | 
| 22 | 
         
            +
                    .input-row {
         
     | 
| 23 | 
         
            +
                        display: flex;
         
     | 
| 24 | 
         
            +
                        justify-content: center;
         
     | 
| 25 | 
         
            +
                        gap: 10px;
         
     | 
| 26 | 
         
            +
                        margin-top: 20px;
         
     | 
| 27 | 
         
            +
                    }
         
     | 
| 28 | 
         
            +
                    .input-row input, .input-row textarea {
         
     | 
| 29 | 
         
            +
                        padding: 10px;
         
     | 
| 30 | 
         
            +
                        font-size: 16px;
         
     | 
| 31 | 
         
            +
                        border: 1px solid #ccc;
         
     | 
| 32 | 
         
            +
                        border-radius: 5px;
         
     | 
| 33 | 
         
            +
                    }
         
     | 
| 34 | 
         
            +
                    #messageInput {
         
     | 
| 35 | 
         
            +
                        width: 80%;
         
     | 
| 36 | 
         
            +
                        margin-top: 20px;
         
     | 
| 37 | 
         
            +
                        min-height: 100px;
         
     | 
| 38 | 
         
            +
                    }
         
     | 
| 39 | 
         
            +
                    #sendButton {
         
     | 
| 40 | 
         
            +
                        color: white;
         
     | 
| 41 | 
         
            +
                        background-color: #4CAF50;
         
     | 
| 42 | 
         
            +
                        border: none;
         
     | 
| 43 | 
         
            +
                        cursor: pointer;
         
     | 
| 44 | 
         
            +
                        padding: 10px 20px;
         
     | 
| 45 | 
         
            +
                        font-size: 16px;
         
     | 
| 46 | 
         
            +
                        border-radius: 5px;
         
     | 
| 47 | 
         
            +
                        margin-top: 20px;
         
     | 
| 48 | 
         
            +
                    }
         
     | 
| 49 | 
         
            +
                    #sendButton:hover {
         
     | 
| 50 | 
         
            +
                        background-color: #388E3C;
         
     | 
| 51 | 
         
            +
                    }
         
     | 
| 52 | 
         
            +
                </style>
         
     | 
| 53 | 
         
            +
            </head>
         
     | 
| 54 | 
         
            +
            <body>
         
     | 
| 55 | 
         
            +
                <h1>Отправка опроса в группу</h1>
         
     | 
| 56 | 
         
            +
                <div class="input-row">
         
     | 
| 57 | 
         
            +
                    <input type="text" id="apiKeyInput" placeholder="Введите API ключ">
         
     | 
| 58 | 
         
            +
                    <input type="text" id="groupIdInput" placeholder="Введите ID группы">
         
     | 
| 59 | 
         
            +
                </div>
         
     | 
| 60 | 
         
            +
                <textarea id="messageInput" placeholder="Введите текст вопроса"></textarea>
         
     | 
| 61 | 
         
            +
                <div class="input-row">
         
     | 
| 62 | 
         
            +
                    <input type="text" id="option1Input" placeholder="Вариант ответа 1">
         
     | 
| 63 | 
         
            +
                    <input type="text" id="option2Input" placeholder="Вариант ответа 2">
         
     | 
| 64 | 
         
            +
                    <input type="text" id="option3Input" placeholder="Вариант ответа 3">
         
     | 
| 65 | 
         
            +
                    <input type="text" id="option4Input" placeholder="Вариант ответа 4">
         
     | 
| 66 | 
         
            +
                </div>
         
     | 
| 67 | 
         
            +
                <button id="sendButton">Отправить опрос</button>
         
     | 
| 68 | 
         
            +
             
     | 
| 69 | 
         
            +
                <script>
         
     | 
| 70 | 
         
            +
                    document.getElementById('sendButton').addEventListener('click', function() {
         
     | 
| 71 | 
         
            +
                        const apiKey = document.getElementById('apiKeyInput').value;
         
     | 
| 72 | 
         
            +
                        const groupId = document.getElementById('groupIdInput').value;
         
     | 
| 73 | 
         
            +
                        const message = document.getElementById('messageInput').value;
         
     | 
| 74 | 
         
            +
                        const option1 = document.getElementById('option1Input').value;
         
     | 
| 75 | 
         
            +
                        const option2 = document.getElementById('option2Input').value;
         
     | 
| 76 | 
         
            +
                        const option3 = document.getElementById('option3Input').value;
         
     | 
| 77 | 
         
            +
                        const option4 = document.getElementById('option4Input').value;
         
     | 
| 78 | 
         
            +
                        if (!apiKey) {
         
     | 
| 79 | 
         
            +
                            alert('Please enter your API key.');
         
     | 
| 80 | 
         
            +
                            return;
         
     | 
| 81 | 
         
            +
                        }
         
     | 
| 82 | 
         
            +
                        if (!groupId) {
         
     | 
| 83 | 
         
            +
                            alert('Please enter the group ID.');
         
     | 
| 84 | 
         
            +
                            return;
         
     | 
| 85 | 
         
            +
                        }
         
     | 
| 86 | 
         
            +
                        if (!message) {
         
     | 
| 87 | 
         
            +
                            alert('Please enter a message.');
         
     | 
| 88 | 
         
            +
                            return;
         
     | 
| 89 | 
         
            +
                        }
         
     | 
| 90 | 
         
            +
                        if (!option1 || !option2 || !option3 || !option4) {
         
     | 
| 91 | 
         
            +
                            alert('Please fill all options.');
         
     | 
| 92 | 
         
            +
                            return;
         
     | 
| 93 | 
         
            +
                        }
         
     | 
| 94 | 
         
            +
                        sendPoll(apiKey, groupId, message, [option1, option2, option3, option4]);
         
     | 
| 95 | 
         
            +
                    });
         
     | 
| 96 | 
         
            +
                    async function sendPoll(apiKey, groupId, message, options) {
         
     | 
| 97 | 
         
            +
                        try {
         
     | 
| 98 | 
         
            +
                            const response = await fetch(`https://api.green-api.com/waInstance1101952913/sendPoll/${apiKey}`, {
         
     | 
| 99 | 
         
            +
                                method: 'POST',
         
     | 
| 100 | 
         
            +
                                headers: {
         
     | 
| 101 | 
         
            +
                                    'Content-Type': 'application/json'
         
     | 
| 102 | 
         
            +
                                },
         
     | 
| 103 | 
         
            +
                                body: JSON.stringify({
         
     | 
| 104 | 
         
            +
                                    chatId: `${groupId}@g.us`,
         
     | 
| 105 | 
         
            +
                                    message: message,
         
     | 
| 106 | 
         
            +
                                    options: options.map(option => ({ optionName: option }))
         
     | 
| 107 | 
         
            +
                                })
         
     | 
| 108 | 
         
            +
                            });
         
     | 
| 109 | 
         
            +
                            if (!response.ok) {
         
     | 
| 110 | 
         
            +
                                throw new Error(`HTTP error! status: ${response.status}`);
         
     | 
| 111 | 
         
            +
                            }
         
     | 
| 112 | 
         
            +
                            const data = await response.json();
         
     | 
| 113 | 
         
            +
                            console.log('Poll sent successfully:', data);
         
     | 
| 114 | 
         
            +
                            alert('Опрос успешно добавлен в группу!');
         
     | 
| 115 | 
         
            +
                        } catch (error) {
         
     | 
| 116 | 
         
            +
                            console.error('Error sending poll:', error);
         
     | 
| 117 | 
         
            +
                            alert('Ошибка при отправке опроса. Пожалуйста, проверьте консоль для деталей.');
         
     | 
| 118 | 
         
            +
                        }
         
     | 
| 119 | 
         
            +
                    }
         
     | 
| 120 | 
         
            +
                </script>
         
     | 
| 121 | 
         
            +
            </body>
         
     | 
| 122 | 
         
            +
            </html>
         
     |