DmitrMakeev
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1627,7 +1627,52 @@ def gc_forms():
|
|
1627 |
|
1628 |
|
1629 |
DATABASE_NAME3 = 'data_gc.db'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1630 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1631 |
def add_or_update_contact(contact_data):
|
1632 |
conn = sqlite3.connect(DATABASE_NAME3)
|
1633 |
cursor = conn.cursor()
|
|
|
1627 |
|
1628 |
|
1629 |
DATABASE_NAME3 = 'data_gc.db'
|
1630 |
+
def verify_phone_number(phone_number):
|
1631 |
+
verifikation_start = "1"
|
1632 |
+
print(f"verifikation_start: {verifikation_start}")
|
1633 |
+
|
1634 |
+
if verifikation_start == "1":
|
1635 |
+
# Переменные окружения для сборки URL
|
1636 |
+
wa_url = "https://api.green-api.com/waInstance"
|
1637 |
+
wa_ak = "1101952913"
|
1638 |
+
ws_url_ver = "/checkWhatsapp/"
|
1639 |
+
wa_api_key = "fb4986a9d9cb40ef9be6c7b08cb9c98b7a3b1dc8c6834b0b92"
|
1640 |
+
|
1641 |
+
full_url_ver = f"{wa_url}{wa_ak}{ws_url_ver}{wa_api_key}"
|
1642 |
+
print(f"Full URL: {full_url_ver}")
|
1643 |
+
|
1644 |
+
# Создаем payload для запроса
|
1645 |
+
payload = json.dumps({
|
1646 |
+
"phoneNumber": phone_number
|
1647 |
+
})
|
1648 |
+
headers = {
|
1649 |
+
'Content-Type': 'application/json'
|
1650 |
+
}
|
1651 |
+
|
1652 |
+
# Отправляем POST-запрос
|
1653 |
+
response = requests.post(full_url_ver, headers=headers, data=payload)
|
1654 |
+
|
1655 |
+
# Печатаем статус ответа
|
1656 |
+
print(f"Response Status Code: {response.status_code}")
|
1657 |
+
|
1658 |
+
# Проверяем статус код ответа
|
1659 |
+
if response.status_code == 200:
|
1660 |
+
# Печатаем текст ответа от сервера
|
1661 |
+
response_body = response.json()
|
1662 |
+
print(f"Response Body: {response_body}")
|
1663 |
|
1664 |
+
# Извлекаем значение из JSON
|
1665 |
+
exists_whatsapp = response_body.get('existsWhatsapp', 'false')
|
1666 |
+
print(f"existsWhatsapp: {exists_whatsapp}")
|
1667 |
+
|
1668 |
+
# Возвращаем значение
|
1669 |
+
return exists_whatsapp
|
1670 |
+
else:
|
1671 |
+
print("Error: Unable to fetch data")
|
1672 |
+
return "Error"
|
1673 |
+
else:
|
1674 |
+
print("Verification not started")
|
1675 |
+
return "Verification not started"
|
1676 |
def add_or_update_contact(contact_data):
|
1677 |
conn = sqlite3.connect(DATABASE_NAME3)
|
1678 |
cursor = conn.cursor()
|