How can I send raw POST data with cURL? (PHP)

curl, php, post

Solution

For some odd reason the aforementioned header thing seems to fix it. Previously it wasn't working, and I'm unsure why it works now.

Anyway, for those who don't know, this is the code:

curl_setopt($handle, CURLOPT_HTTPHEADER, array('Content-Type: text/plain'));

Problem

I'm attempting to send raw POST data to a page using $HTTP_RAW_POST_DATA, but my attempts failed and an undefined index notice was given. I have attempted the following: ``` curl_setopt($handle, CURLOPT_POSTFIELDS, 'Raw POST data'); // Doesn't seem to work at all. curl_setopt($handle, CURLOPT_POSTFIELDS, array('Raw POST data')); // 0 => Raw POST data ``` I did some research and some people had suggested sending a header (Content-Type: text/plain) in the request, which didn't seem to affect anything. Is there a solution for this issue?

Original source

Related problems