简体   繁体   English

使用 API 访问当天的 WhatsApp 消息

[英]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.

相关问题 如何使用 python 读取联系人的 whatsapp 消息? - How do I read whatsapp messages from a contact using python? 匹配来自Python中WhatsApp日志的消息 - Match messages from WhatsApp log in python 回复传入的媒体消息| Twilio Whatsapp API | 内部服务器错误 - Reply to Incoming Media Messages | Twilio Whatsapp API | Internal Server Error 使用python的twitter api发布消息 - using twitter api from python to post messages 如何为从我的whatsapp消息导出的日期时间编写正则表达式代码 - how to write the regex code for the datetime exported from my whatsapp messages 响应 Whatsapp 消息的程序 - Program to respond to Whatsapp messages 无法使用 whatsapp 业务 api 将我传入的 whatsapp 消息标记为已读 - can not mark as read my incoming whatsapp message using whatsapp business api 使用 Twilio API,Whatsapp 批准的 Twilio 号码,预先批准的模板,无法接收 whatsapp 消息 - Using the Twilio API, Whatsapp approved Twilio number, pre-approved template, unable to receive whatsapp message 使用 WhatsApp API 发送存储在 Google Drive 上的媒体时出错 - Error while sending media stored on Google Drive using WhatsApp API 如何从whatsapp cloud api中的消息ID获取消息对象? - how to get message object from message id in whatsapp cloud api?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM