Pokaż nagłówki żądań Curl POST? Jest na to sposób?

I 'm building a curl web automation app and am having some problem with not getting the desired result of my post action, I' m having some trouble zastanawiając się, jak mogę pokazać pełne żądanie POST wysyłam nad (z nagłówkami), i have been searching on this but everything that comes up is the response headers, actually I want these too but also the request, which no of the posts I find on google seem to mention..

Wiem, że mogę wyświetlić wynik żądania curl za pomocą coś takiego (wybacz mi, jeśli moja składnia jest wyłączona, już wyłączyłem moją maszynę wirtualną z moim ide i kodem, aby odnieść się do

 $result = curl($curl_exect) ;

W każdym razie, byłbym bardzo wdzięczny za wszelkie porady, Jak wyświetlić pełne nagłówki, dzięki

Author: Rick, 2010-07-02

5 answers

Możesz zobaczyć informacje dotyczące transferu wykonując:

curl_setopt($curl_exect, CURLINFO_HEADER_OUT, true);

Przed żądaniem, oraz

$information = curl_getinfo($curl_exect);

Po zapytaniu

Widok: http://www.php.net/manual/en/function.curl-getinfo.php

Możesz również użyć CURLOPT_HEADER w swoim curl_setopt

curl_setopt($curl_exect, CURLOPT_HEADER, true);

$httpcode = curl_getinfo($c, CURLINFO_HTTP_CODE);

if($httpcode == 200) {
    return true;
}

return false;

To tylko niektóre metody używania nagłówków.

 59
Author: RobertPitt,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2016-10-16 15:51:11

Oto wszystko, czego potrzebujesz:

curl_setopt($curlHandle, CURLINFO_HEADER_OUT, true); // enable tracking
... // do curl request    
$headerSent = curl_getinfo($curlHandle, CURLINFO_HEADER_OUT ); // request headers
 152
Author: Joseph Lust,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2012-04-27 21:15:37

Możesz zapisać wszystkie nagłówki wysłane przez curl do pliku używając :

$f = fopen('request.txt', 'w');
curl_setopt($ch,CURLOPT_VERBOSE,true);
curl_setopt($ch,CURLOPT_STDERR ,$f);
 8
Author: Nassim Aouragh,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-10-01 16:31:30

Możesz sprawić, że poprosisz o nagłówki samodzielnie, używając:

// open a socket connection on port 80
$fp = fsockopen($host, 80);

// send the request headers:
fputs($fp, "POST $path HTTP/1.1\r\n");
fputs($fp, "Host: $host\r\n");
fputs($fp, "Referer: $referer\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: ". strlen($data) ."\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $data);

$result = ''; 
while(!feof($fp)) {
    // receive the results of the request
    $result .= fgets($fp, 128);
}

// close the socket connection:
fclose($fp);

Like writen on how make request

 5
Author: Liutas,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2010-07-02 09:24:05

Ostatnio miałem dokładnie ten sam problem i zainstalowałem Wireshark(jest to narzędzie do monitorowania sieci). Możesz zobaczyć wszystko z tym, z wyjątkiem szyfrowanego ruchu (HTTPS).

 3
Author: greg0ire,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-11-20 09:53:24