aherlambang
aherlambang

Reputation: 14418

getting http post response body using curl

So I have the following code snippet

$ch = curl_init();

//Set the URL
curl_setopt($ch, CURLOPT_URL, $jURL);
//Enable curl response
curl_setopt(CURLOPT_RETURNTRANSFER, true);
//Enable POST data
curl_setopt($ch, CURLOPT_POST, true);
//Use the $pData array as the POST data
curl_setopt($ch, CURLOPT_POSTFIELDS, $jData);

$result = curl_exec($ch);

echo 'The body of the response is ' . $result;

curl_close($ch);

I would like to get the response body printed out, however my code above prints the number 1. Is there a way to get the response here?

Upvotes: 0

Views: 12585

Answers (1)

Dave
Dave

Reputation: 1216

You are missing the first argument:

curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);

Upvotes: 8

Related Questions