php - echoing request with fputs -
i'm using code below, post request api. debugging purposes: there way echo full request (including header) sent code?
$data = http_build_query($requests); $url = parse_url($urlfull); $host = $url['host']; $path = $url['path']; $fp = fsockopen('ssl://'.$host, 443, $errno, $errstr, 30); if ($fp){ fputs($fp, "post $path http/1.1\r\n"); fputs($fp, "host: $host\r\n"); fputs($fp, "pragme: no-cache\r\n"); fputs($fp, "content-length: ". strlen($data) ."\r\n"); fputs($fp, "content-type: application/x-www-form-urlencoded\r\n\r\n"); fputs($fp, $data); $result = ''; while(!feof($fp)) { $result .= fgets($fp, 4096); } } else { $errors = array( 'status' => 'err', 'error' => "$errstr ($errno)" ); } fclose($fp);
Comments
Post a Comment