我正在关注更新whatsapp个人资料图片的文档。
我成功将jpg图片上传到可断点上传API,并获取了文件句柄。但是当使用文件句柄更新 Whatsapp 配置文件时,我收到一个奇怪的错误。
要求:
curl -X POST \
'https://graph.facebook.com/v14.0/PHONE_NUMBER_ID/whatsapp_business_profile' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-d '{
"messaging_product": "whatsapp",
"address": "ADDRESS",
"description": "DESCRIPTION",
"vertical": "INDUSTRY",
"email": "EMAIL",
"websites": [
"https://WEBSITE-1",
"https://WEBSITE-2"
],
"profile_picture_handle": "4::aW1hZ2UskdjfFEw==:ARb......"
}'
回应:
{
"message":"An unknown error occurred",
"type":"OAuthException",
"code":1,
"error_subcode":3441012,
"is_transient":false,
"error_user_title":"Image type not supported",
"error_user_msg":"Please upload JPG image.",
"fbtrace_id":"ANhxQ6Pn-VLvrRSMtmFb24I"
}
我AM上传JPG图像(尝试了多个JPG)!
//you have to call api this way to get file handle
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, https://graph.facebook.com/{api-version}/{upload-session-id});
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, 1);
$headers = [
"Authorization: OAuth $accessToken",
"file_offset: 0",
];
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents('Your-File-Full-Path'));
$response = curl_exec($ch);
if (curl_errno($ch)) {
return 'Curl error: ' . curl_error($ch);
}
and then call_user_func
curl -X POST \
'https://graph.facebook.com/v14.0/PHONE_NUMBER_ID/whatsapp_business_profile' \
-H 'Authorization: Bearer ACCESS_TOKEN' \
-d '{
"messaging_product": "whatsapp",
"address": "ADDRESS",
"description": "DESCRIPTION",
"vertical": "INDUSTRY",
"email": "EMAIL",
"websites": [
"https://WEBSITE-1",
"https://WEBSITE-2"
],
"profile_picture_handle": "4::aW1hZ2UskdjfFEw==:ARb......"
}'
This Will Work Definitely.