[英]Access WhatsApp messages from the day using API
I am building an application using the WhatsApp Business Cloud API. Essentially I want to know if it's possible to build an application that collects all the messages from the day and downloads it.我正在使用 WhatsApp Business Cloud API 构建一个应用程序。本质上,我想知道是否可以构建一个应用程序来收集当天的所有消息并进行下载。 Specifically the media attached to it using the API. As far as I know you can use webhooks to get incoming messages.
特别是使用 API 附加到它的媒体。据我所知,你可以使用 webhooks 来获取传入的消息。 But in order to do this the application has to be run forever, and my cousin has a problem with this as it could cause problems to run an application forever vs just run it once a day.
但是为了做到这一点,应用程序必须永远运行,而我的堂兄对此有疑问,因为它可能会导致永远运行应用程序与每天运行一次相比出现问题。 I'm able to send messages using the API and a python wrapper but that's much more simple than what I'm trying to do.
我可以使用 API 和 python 包装器发送消息,但这比我尝试做的要简单得多。 Aditionally, there is an option of using selenium but that's not really an automated solution to what we're trying to do because everytime selenium executes the browser we'd need to log in using the QR code.
此外,还有一个使用 selenium 的选项,但这并不是我们正在尝试做的事情的真正自动化解决方案,因为每次 selenium 执行浏览器时,我们都需要使用二维码登录。 If anyone has any idea if this is possible (or not possible) I'd be very appreciative!
如果有人知道这是否可能(或不可能),我将不胜感激!
from heyoo import WhatsApp
import logging
import requests
from dotenv import load_dotenv
from flask import Flask, request, make_response
app = Flask(__name__)
token = 'EAAVk5rqOCsABAAcPPrZC6GnlZAJuykdFIQd4DhkuRVNeGntfFOU5jaK4jG2yCZBS6i7kFQGk3kRvDP0fExBXRsFyqWUqfVVJsSxeQdcA9XHWpRuUsnnuwqLcZAQpwTiuoZCXv4ixCcHYlPEe6NGHupCalHvWw9NQRoZAVnegU5ZCBvX6eO9E8vyum1lQ2SSt7OuUpdpIkmkyBK8tiEL8rpGwM8RrqZA3A10ZD'
messenger = WhatsApp(token, phone_number_id='100398242927044')
messenger.send_message('Hey its JJ ', '1xxxxxxxx')
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
print("hello")
@app.route("/", methods=["GET", "POST"])
def hook():
//some code that isn't working yet //一些还没有工作的代码
I'm new to all of this stuff so I don't really know how to set up a webhook either but my cousin who's business I'm building this app for doesn't ideally want to use a webhook.我是所有这些东西的新手,所以我真的不知道如何设置 webhook,但我正在为其构建此应用程序的表弟并不理想地希望使用 webhook。
You can use ngrok server, which provides:您可以使用ngrok服务器,它提供:
how to use ngrok to integrate your localhost app with WhatsApp by using Webhooks.
如何使用 ngrok 通过 Webhooks 将您的本地主机应用程序与 WhatsApp 集成。 WhatsApp webhooks can be used to notify an external application whenever specific events occur in your WhatsApp account
WhatsApp webhooks 可用于在您的 WhatsApp 帐户中发生特定事件时通知外部应用程序
https://ngrok.com/docs/integrations/whatsapp/webhooks https://ngrok.com/docs/integrations/whatsapp/webhooks
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.