I'm having an issue with an API saying it get the wrong data, but when I look at what I send to curl it seems to be perfectly fine.
But I can't find a way to see exactly what cURL is sending. I can only figure out how to see the headers, not the body of the request I'm sending.
Does anyone know how I can see the actual raw data, including the body of the request that is sent? While not really necessary, I included my code below for good measure.
If found a few similar questions on stackoverflow, but they were all unanswered/solved in other ways.
private function createCurl( $url, $http_context ) {
$ch = curl_init( $url );
$curl_opts = array(
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_SSL_VERIFYPEER => false
);
$curl_opts[ CURLOPT_CUSTOMREQUEST ] = $http_context['method'];
if ( ! empty( $http_context['content'] ) ) {
$curl_opts[ CURLOPT_POSTFIELDS ] =& $http_context['content'];
}
$curl_opts[ CURLOPT_HTTPHEADER ] = array_map( 'trim', explode( "\n", $http_context['header'] ) );
if ( ! empty( $this->curlOptions ) && is_array( $this->curlOptions ) ) {
$curl_opts = array_merge( $curl_opts, $this->curlOptions );
}
curl_setopt_array( $ch, $curl_opts );
return $ch;
}
private static function &execCurlAndClose( $ch, &$out_response_headers = null ) {
if ( is_array( $out_response_headers ) ) {
self::$_curlHeadersRef =& $out_response_headers;
curl_setopt( $ch, CURLOPT_HEADERFUNCTION, array( __CLASS__, '_curlHeaderCallback' ) );
}
$res = curl_exec( $ch );
$err_no = curl_errno( $ch );
$err_str = curl_error( $ch );
curl_close( $ch );
return $res;
}