我正在尝试使用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.
发布评论
评论(2)
在
但是,我使用
profile_picture_handle
而不是profile> profile> profile_picture_url
。那么,我们如何获得profile_picture_handle
?先决条件:
更新照片配置文件:
发布https://graph.facebook.com/v14.0/ {{appid}}}}}}}/uploads?access_token= {token} {token} {token}& plile_length = {filesizeinbyte}}} file_type = image/jpeg
上传:xxxxxx?sig = xxxxxxx
。发布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 :: xxx ==:xxxxxx
。发布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:
But, i got it working using
profile_picture_handle
instead ofprofile_picture_url
. So how do we get theprofile_picture_handle
?Prerequisite:
Update Photo Profile:
POST https://graph.facebook.com/v14.0/{{appId}}/uploads?access_token={{token}}&file_length={{fileSizeInByte}}&file_type=image/jpeg
upload:XXXXXX?sig=XXXXXX
.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).4::XXX==:XXXXXX
.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.
您必须通过选择“承载者”来添加您拍摄的最后一步,否则会给您带来错误。我在最后一个步骤上很难做,然后执行以下链接,这应该有所帮助。
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