i am trying to get all the headers from a site print_r(get_headers('http://example.com')); PHP: However this only returns one array of header and stops how do i make to collect all the headers ?
Why it stops? It's not stops.. For example: <?php $arr = array(); $arr = get_headers( 'http://google.com' ); echo $arr[0] . '<br />some text...'; ?> Code (markup): So you can collect all the headers in an array...
Array ( [0] => HTTP/1.1 200 OK [1] => Date: Sun, 05 Oct 2008 18:18:00 GMT [2] => Server: Apache [3] => Set-Cookie: bbsessionhash=15a29a50f601ec4f74261f9cffd4f5f5; path=/; HttpOnly [4] => Set-Cookie: bblastvisit=1223230680; expires=Mon, 05-Oct-2009 18:18:00 GMT; path=/ [5] => Set-Cookie: bblastactivity=0; expires=Mon, 05-Oct-2009 18:18:00 GMT; path=/ [6] => Cache-Control: private [7] => Pragma: private [8] => Connection: close [9] => Content-Type: text/html; charset=UTF-8 ) Code (markup): it gives something like this but it sends out more headers which it doesnt catch (ff livehttp extension)
If it doesn't display them, they weren't sent. The server you're fetching them from might be reacting to the USER_AGENT used by PHP to fetch the headers, and withholding headers.
All right after using user agent it sends one more header (but it sends more headers and same result with curl with cookie)
The trick is going to be imitating the way a browser would be making the request. Keep looking, there's bound to be something you're missing while making the request somewhere.
if you have curl installed use this to connect to an external site and use the setop_headers to return the headers.. with curl u can specify user agents and more to get the result you need...