WhatsApp Cloud API更新个人资料图片

发布于 2025-02-03 18:02:01 字数 1221 浏览 3 评论 0 原文

我正在尝试使用WhatsApp Cloud API *上传图像作为个人资料图片。

使用WhatsApp Cloud API创建应用程序后,我不允许使用常规应用程序也不使用业务应用程序访问。它说了“在一小时内重试”之类的东西。因此,我必须使用API​​实施所有内容。

阅读文档并导入

https://graph.facebook.com/ {{version}}}/{{phone-number-id}}/whatsapp_business_profile

它具有字段“ profile_picture_url_url “ 我尝试发布媒体 https://graph.facebook.com/ {{version}}}}/{{phone-number-id}}/媒体,然后使用给定id y使用的 https://graph.facebook.com/ {{version}}}/{{Media-id}}} 获取URL,但它不起作用。其余信息将成功更新

{
    "messaging_product": "whatsapp",
    "address": "",
    "description": "Simple Bot",
    "email": "[email protected]",
    "websites": [
        "https://..."
    ],
    "profile_picture_url": "https://lookaside.fbsbx.com/..."
}

,但是如果我尝试使用ID发送某人,并且端点 https://graph.facebook.com/ {{version}}}/{{phone-number-id}}/消息它可以正常工作。 而且,如果我使用postman中的URL下载媒体内容,它也可以正常工作。

我不知道我是否误解了某些事情,还是使用API​​无法完成。

I'm trying to upload an image as profile picture using WhatsApp Cloud API *.

After creating an application using WhatsApp Cloud API I'm not allowed to access neither using the regular application nor using Business Application. It says something like "try again in one hour". So I have to implement everything using the API.

After reading the docs and importing Postman Endpoints I found the one called Business Profiles > Update Business Profile

https://graph.facebook.com/{{Version}}/{{Phone-Number-ID}}/whatsapp_business_profile

It has a field "profile_picture_url"and I have tried POSTing media https://graph.facebook.com/{{Version}}/{{Phone-Number-ID}}/media and then with the given ID y used https://graph.facebook.com/{{Version}}/{{Media-ID}} to get the URL but it didn't work. The rest of the information is updated successfully

{
    "messaging_product": "whatsapp",
    "address": "",
    "description": "Simple Bot",
    "email": "[email protected]",
    "websites": [
        "https://..."
    ],
    "profile_picture_url": "https://lookaside.fbsbx.com/..."
}

However if I try to send someone using the ID and the endpoint https://graph.facebook.com/{{Version}}/{{Phone-Number-ID}}/messages it works fine.
And if I use Download Media Content with the URL in Postman it works fine too.

I don't know if I have misunderstood something or if it can't be done using the API.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉城メ夜风 2025-02-10 18:02:01

profile_picture_url(可选):从调用到“ noreferrer”>可重新上传API

但是,我使用 profile_picture_handle 而不是 profile> profile> profile_picture_url 。那么,我们如何获得 profile_picture_handle

先决条件:

  1. Graph api令牌在这里。或使用您的WhatsApp Cloud API令牌。
  2. 应用ID,go apps >您的应用程序>设置(侧栏菜单)>基本

更新照片配置文件:

  1. 呼叫发布https://graph.facebook.com/v14.0/ {{appid}}}}}}}/uploads?access_token= {token} {token} {token}& plile_length = {filesizeinbyte}}} file_type = image/jpeg
  2. 保存您获得的会话ID,上传:xxxxxx?sig = xxxxxxx
  3. 调用发布https://graph.facebook.com/v14.0/ {{sessionId}} ,带标头:授权= oauth = oauth {{token}},file_offset = 0,host = graph.facebook.com,connection =关闭,content-type = multipart/form-data ,并将您的映像文件包含在带有type dinary的请求主体中。如果您使用邮递员,请参见下面的图像(这是我错过的几个小时)。
  4. 保存您获得的手柄结果, 4 :: xxx ==:xxxxxx
  5. 最后,调用发布https://graph.facebook.com/ {{{version}}/{{phone-number-id}}}/whatsapp_business_profile ,带有json request hody: “:“ whatsapp”,“ profile_picture_handle”:“ 4 :: xxx ==:xxxxxx”}

就是这样,您可以检查配置文件图片。

It is mentioned in the Cloud API Documentation:

profile_picture_url (Optional): URL of the profile picture generated from a call to the Resumable Upload API.

But, i got it working using profile_picture_handle instead of profile_picture_url. So how do we get the profile_picture_handle?

Prerequisite:

  1. Graph API token here. Or use your WhatsApp Cloud API token.
  2. App ID, go Apps > Your App > Settings (sidebar menu) > Basic

Update Photo Profile:

  1. Call POST https://graph.facebook.com/v14.0/{{appId}}/uploads?access_token={{token}}&file_length={{fileSizeInByte}}&file_type=image/jpeg
  2. Save the session id you got, upload:XXXXXX?sig=XXXXXX.
  3. Call POST https://graph.facebook.com/v14.0/{{sessionId}}, with the headers: Authorization=OAuth {{token}}, file_offset=0, Host=graph.facebook.com, Connection=close, Content-Type=multipart/form-data, and include your image file in the request body with type binary. If you using Postman, see image below (This is what I missed for hours). enter image description here
  4. Save the handle result you got, 4::XXX==:XXXXXX.
  5. Finally, call POST https://graph.facebook.com/{{Version}}/{{Phone-Number-ID}}/whatsapp_business_profile, with json request body: {"messaging_product": "whatsapp", "profile_picture_handle": "4::XXX==:XXXXXX"}

That's it, You can check the profile picture.

波浪屿的海角声 2025-02-10 18:02:01

您必须通过选择“承载者”来添加您拍摄的最后一步,否则会给您带来错误。我在最后一个步骤上很难做,然后执行以下链接,这应该有所帮助。

https://web.postman.co/workspace/My-Workspace~a4ddb3b8-02a3-4132-8384-66e63e149b7b/request/22958165-506a0542-c845-41ac-b3fb-b8209fd6f53b

The last step you have to add your taken by selecting "Bearer" or else it will give you error. I had hard time on the last ones, do all the steps and then go to the following link and it should help.

https://web.postman.co/workspace/My-Workspace~a4ddb3b8-02a3-4132-8384-66e63e149b7b/request/22958165-506a0542-c845-41ac-b3fb-b8209fd6f53b

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文