简体   繁体   English

使用 WhatsApp API 发送存储在 Google Drive 上的媒体时出错

[英]Error while sending media stored on Google Drive using WhatsApp API

I'm trying to send a image stored Google Drive via WhatsApp API using 360Dialog, I did set the provider as instructed in https://developers.facebook.com/docs/whatsapp/api/settings/media-providers#example-2 I'm trying to send a image stored Google Drive via WhatsApp API using 360Dialog, I did set the provider as instructed in https://developers.facebook.com/docs/whatsapp/api/settings/media-providers#example-2

POST /v1/settings/application/media/providers
[{
    "name": "google-drive",
    "type": "www",
    "config": {
        "bearer": "your-bearer-token" #(Replaced the value here with API KEY)
    }
 }
]  

and it successfully returns the provider information, but when I execute the code它成功返回提供者信息,但是当我执行代码时

import requests
import json

url = "" #360Dialog url

payload = json.dumps({
  "recipient_type": "individual",
  "to": "",
  "type": "image",
  "image": {
    "link": "", #I've set the link key as the URL of the image I have on my google drive
    "provider": {
      "name": "google-drive"
    },
    "caption": "your-image-caption"
  }
})
headers = {
  'D360-API-KEY': '',
  'Content-Type': 'application/json'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Error:错误:

"errors": [
        {
          "code": 1000,
          "title": "Image file format (text/html) is not supported"
        }
      ]

Have you tested with other image sources?您是否使用其他图像源进行了测试? It seems like Google Drive is giving you a web view of the image instead of the physical image itself... Thats why the error says that you should provide an image format and not a text/html in the response header of the image source.似乎 Google Drive 正在为您提供图像的 web 视图而不是物理图像本身......这就是为什么错误说您应该在图像源的响应 header 中提供图像格式而不是text/html的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Python Google Drive API无法使用mediaFileUpload插入媒体文件 - Python Google drive API cannot insert media file using mediaFileUpload Whatsapp 云 API 上传媒体使用 python 获取错误文件类型 - Whatsapp cloud API uploading media get error file type using python 有没有办法在使用 gdrive API 将文件上传到谷歌驱动器时重命名文件? - Is there a way to rename a file while uploading it to google drive using gdrive API? 回复传入的媒体消息| Twilio Whatsapp API | 内部服务器错误 - Reply to Incoming Media Messages | Twilio Whatsapp API | Internal Server Error Python:使用`export_media`(Google Drive API)下载PDF时传递`gridlines=false` - Python: Pass `gridlines=false` when downloading a PDF using `export_media` (Google Drive API) 如何将alt = media与Google Drive Python API结合使用? - How to use alt=media with Google Drive Python API? Google Drive Python API; 上传一个不是文件的媒体对象 - Google Drive Python API; upload a media object which is NOT a file 使用Google Drive API SDK从Google Drive删除文件 - Delete file from Google Drive using Google Drive API SDK 从 Google Drive 获取 Whatsapp 备份文件 - Getting Whatsapp Backup file from Google Drive Python Google Drive API的SSL错误 - SSL Error with Python Google Drive API
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM