Non 100% sûr de ce que vous voulez dire ...
Si vous voulez saisir une page, et remplacer le contenu/insérer du contenu - vous pouvez faire quelque chose comme ceci:
$ch = curl_init("http://stackoverflow.com/questions/1361169/possible-to-add-data-to-the-body-of-a-http-request-using-curl-in-php");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
$output = curl_exec($ch);
$output = str_replace('Possible to add data to the body of a HTTP request using cURL in PHP?', 'I have just changed the title of your post...', $output);
echo $output;
Ceci imprimer cette page ...
EDIT:
Avec les nouvelles informations ajoutées, je pense que vous devriez être en mesure d'utiliser les POSTFIELDS .. Rappelez-vous juste de mettre le POST à 1 ..
E.g. (quelque chose comme ça - pas testé)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://stackoverflow.com");
curl_setopt($ch, CURLOPT_USERAGENT, "My user agent");
curl_setopt($ch, CURLOPT_HTTPHEADER, $myOtherHeaderStringVariable);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "I want to add data to the request here");
$output = curl_exec($ch);
Quel type de données? En-têtes supplémentaires? – Lodle
En-têtes supplémentaires au corps? – Zed