import json
phone_number_id = "xxx" # Your WhatsApp Cloud API phone number ID
access_token = "xxx"
template_name = "hello_world"
# Replace with the recipient's phone number in E.164 format:
recipient_phone = "whatsapp:+420602xxxxxx"
# WhatsApp Cloud API endpoint URL
url = f"https://graph.facebook.com/v15.0/{phone ... }/messages"
# HTTP headers
headers = {
"Authorization": f"Bearer {access_token}",
"Content-Type": "application/json"
}
# Payload for sending a WhatsApp template message
payload = {
"messaging_product": "whatsapp",
"to": recipient_phone,
"type": "template",
"template": {
"name": template_name,
"language": {"code": "en_us"},
"components": [
{
"type": "body",
"parameters": [
]
}
]
}
}
# Send the POST request
response = requests.post(url, headers=headers, json=payload)
# Check and print the response
if response.ok:
print("Message sent successfully:")
print(json.dumps(response.json(), indent=2))
else:
print("Failed to send message:")
print(response.status_code, response.text)
< /code>
Если я изменяю мир Hello на то же самое, но мой собственный создан под названием «my_hello_world». Я получаю эту ошибку: < /p>
Failed to send message:
400 {"error":{"message":"(#135000) Generic user error","type":"OAuthException","code":135000,"error_data":{"messaging_product":"whatsapp","details":"Generic user error"},"fbtrace_id":"AhxqWmU7Cl1iiCR-Jj7WD7A"}}
< /code>
Все, что реже, верно: < /p>
- Идентификатор цифр телефона < /li>
- Recupient Phone
- Имя шаблона (я пробовал по -другому, и он дает мне ошибку Diff)
Различный профиль < /li>
Различный номер отправки < /li>
Шаблон воссоздания < /li>
Используемый шаблон без каких -либо параметров, заголовки < /li>
Различные языки шаблона (теперь используя en_us) в качестве по умолчанию Hello World < /li>
< /ul>
Вот мой предыдущий вопрос, где я использовал make.com, чтобы позвонить в API с тем же результатом. < /p>
Вот фотографии Шаблоны:
Подробнее здесь: https://stackoverflow.com/questions/794 ... sage135000