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
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.
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
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);
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
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).
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