Php Curl Get Response Body

[Solved] Php Curl Get Response Body | Php - Code Explorer | yomemimo.com
Question : php curl post json

Answered by : -1vajs8k9qntw

$ch = curl_init( $url );
# Setup request to send json via POST.
$payload = json_encode( array( "customer"=> $data ) );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
# Return response instead of printing.
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
# Send request.
$result = curl_exec($ch);
curl_close($ch);

Source : https://stackoverflow.com/questions/11079135/how-to-post-json-data-with-php-curl | Last Update : Mon, 12 Jul 21

Question : php curl get response body

Answered by : jareer

$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
$response = curl_exec($ch);
// Then, after your curl_exec call:
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);

Source : https://stackoverflow.com/a/9183272/12398332 | Last Update : Sat, 25 Dec 21

Question : php curl get body response

Answered by : akbarali

curl_setopt($ch, CURLOPT_HEADER, false);

Source : | Last Update : Wed, 29 Dec 21

Answers related to php curl get response body

Code Explorer Popular Question For Php