Click here to Skip to main content
15,885,953 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get the id from the response when I use postman it works fine but when I try to do in vs code with php curl it shows,
JSON
{
    "error": {
        "message": "(#100) The parameter messaging_product is required.",
        "type": "OAuthException",
        "code": 100,
        "fbtrace_id": "An1nMSXpHU5KfaQ1vn5xo8s"
    }
}

my code is,
PHP
 'https://graph.facebook.com/v16.0/*******/media',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => array('file'=> new CURLFILE('/C:/xaamp/htdocs/mdu_child_app/app/uploads/TrueConnect Platform (1).png'),'messaging_product' => 'whatsapp'),
  CURLOPT_HTTPHEADER => array(
    '********',
    'Content-Type: image/png'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;


What I have tried:

I have also tried to upload the image file on the server and get the destination to the 'file' request.
still receiving the same output. what changes should I do?
Posted
Updated 11-Apr-23 22:23pm
v2

1 solution

Your content type header needs to be multipart/form-data, and you'll probably need to provide a boundary value:

curl - Send file using multipart/form-data request in php - Stack Overflow[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900